November 19th, 2000, 03:32 PM
I am wondering how you check if an element in a table CAN be null or not (ie if it was declared with the NOT NULL directive or not). How do you do this??
November 19th, 2000, 07:21 PM
Issue a "show columns from table" query, parse through each row looking for the column in question, then see if that row also has not null in it.
Insert a null value and see if it works. Then delete it if neccessary.
INSERT INTO test (column_name) VALUES (null);
Notice no quotes around null.
November 20th, 2000, 03:51 AM
To display the table definitions from the MySql command prompt:
November 20th, 2000, 06:33 AM
"desc tablename" and "show columns from tablename" give the same output, btw.
Any command you can give from the command line can be given in a mysql_query() command.