We have a MySQL table that was altered with
ALTER TABLE t COMMENT 'foo'
we later realize that we don't want that comment. Is there a way to delete it?
simply saying
ALTER TABLE t COMMENT 'NOT foo'
simply adds an additional comment, so that when you do a SHOW CREATE TABLE t it shows BOTH comment开发者_StackOverflow中文版s...
ETA:
AH, the problem seems to be that My PHP that is working with the comment can't tell the difference between a comment from an ADD COLUMN and a comment which is just about the whole table...
So, now what I need to do is delete replace the COLUMN comment...
ALTER TABLE t COMMENT '';
should work.
Example:
ALTER TABLE test_table COMMENT 'foo';
SHOW CREATE TABLE test_table;
results in:
CREATE TABLE `test_table` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='foo'
followed by
ALTER TABLE test_table COMMENT '';
SHOW CREATE TABLE test_table;
results in:
CREATE TABLE `test_table` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
ALTER TABLE t COMMENT ''
ALTER TABLE t COMMENT = ''
精彩评论