【Foreword】
When designing the database, it is convenient for developers to query and identify, so sql allows to add comments
【main body】
1. Write a comment when creating a table
create table test1( field_name int comment 'Comment of the field' )comment='Comment of the table';
2. Modify the comments of the table
alter table test1 comment 'The comment of the modified table';
3. Modify the comment of the field
alter table test1 modify column field_name int comment 'Modified field comment';
--Note: just write the field name and field type as written
4. Ways to view table comments
-- look in the generated SQL statement
show create table test1;
-- look in the metadata table
use information_schema; select * from TABLES where TABLE_SCHEMA='my_db' and TABLE_NAME='test1' \G
5. How to view field annotations
--show
show full columns from test1;
-- look in the metadata table
select * from COLUMNS where TABLE_SCHEMA='my_db' and TABLE_NAME='test1' \G
.