Frage

I have a table with 80 fields in it.

I would like to globally set the NULL value for each field to YES. Is this possible?

War es hilfreich?

Lösung

Not "natively", no; You have to specify field names verbatim in ALTER TABLE.

You could script it, but by the time you've loaded up SO, asked this question, got this response, found out how to script it and what in, and gone and done it.... well, you could have just spent the 60 seconds it'll take to make this change manually through SQLYog.

Andere Tipps

You would likely have to write a function to do it, as iteration in MySQL isn't really supported by plain old queries afaik. The meta-data for the columns you would likely pull off of the information_schema table with a query for

select column_name from `information_schema`.`columns` where table_name = 'myTable';

give that a shot and see how far you get :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top