Jay Moore wrote:
revDAVE wrote:
Hi Folks,
Newbie question....
I have a mysql table with 100 fields, currently all do not allow nulls.
Rather than hand typing in phpMyAdmin, I would like a way to loop
through
all fields and update them to allow nulls....
First I would DESCRIBE the table so you get a list of column names and
attributes. Then I would go thru each column and CHANGE it so it has
the same attributes, adding the NULL flag if necessary.
There may be an easier way however.
Jay
I wouldn't bother mixing in PHP in all this.
In the mysql client, do a SHOW CREATE TABLE tableName\G
(The \G will save you from seeing lots of wrapping ---------'s)
Copy the returned CREATE TABLE statement, paste into your editor. Re-use
the column definitions to craft the appropriate ALTER TABLE statement.
Run in your mysql client, after testing on a copy of the table, or
backup your data first, whichever is appropriate to your situation..
For a PHP solution, PEAR MDB2 (specifically the Manager and Reverse
modules) could be used, but I would only use it for recurring situations
where a generic solution is appropriate, not for a one-off operation
like this seems to be.
Cheers,
Mattias
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php