How to do it with mysql-cli? table comment
means for example foo
below:
create table t (c1 int) comment='foo';
you can use mysql> alter table t comment='f1';
mysql> commit;
As far as I know it is impossible to achieve that with an alter. Instead, I would do the following:
Run
show create table t;
and save the result somewhere (clipboard or file, whatever)
Run
create table t_temp ...
(where... is the continuation of the command, do not take that literally, see Step 1 )
Run
insert into t_temp(...)
select ...
from t;
where ...
represents the column list. Again, do not take this literally.
Run
drop table t;
alter table t_temp rename t;
I strongly recommend that you back up your database regularly and specifically before you do such large changes to avoid irreparable data-loss.
Check if this answers your question. stackoverflow.com/questions/2162420/alter-mysql-table-to-add-comments-on-columns
thanks. @JoseLora
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.