DISABLE ADBLOCK

ADBlock is blocking some content on the site

ADBlock errore

MYSQL Table Structure Global Null Value

StackOverflow https://stackoverflow.com/questions/9351094

Question

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?

Solution

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.

OTHER TIPS

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 :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow