tags:

views:

67

answers:

3

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 comments...

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...

+4  A: 
ALTER TABLE t COMMENT ''
cherouvim
+3  A: 

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
zombat
+1  A: 
ALTER TABLE t COMMENT = ''
sp