It is a very good idea, and often overlooked, to create a table comment when creating a table. Months later when you’ve forgotten what eggs_x_chickens was for, the comment will be extremely useful. It is especially useful if multiple people will be accessing the database, but you should go to the effort to do it even if the table is for your private consumption.
CREATE TABLE testing ( name VARCHAR(5) ) COMMENT='this is testing';
How to view the comment:
SHOW CREATE TABLE testing;
+---------+--------------------------------------------------------- | Table | CreateTable | +---------+--------------------------------------------------------- | testing | CREATE TABLE `testing` ( `name` varchar(5) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='this is testing' | +---------+---------------------------------------------------------
Even more often overlooked: if you’ve repurposed or redesigned a table an out of date comment should be updated, because an incorrect table comment is worse than none at all.
ALTER TABLE tablename COMMENT = 'new updated comment';
If you liked this post, check out Seven Deadly SQL Sins series at hubpages. Are you making any of these potentially career-ending mistakes with SQL?
Listen to this post| 3.4 |














I really need to get to grips with MYSQL as well as other stuff like PHP and html. The skills would definitely come in handy with my internet stuff, but all the computer language gives me nothing but a headache at times.
Phone Boys last blog post..Scientists Study Risks Of Long-Term Mobile Phone Use