MySql creates tables with interpretations and implementation code for annotating tables and fields

  • 2021-06-28 14:20:03
  • OfStack

1 Create tables with explanations


CREATE TABLE groups( 
 gid INT PRIMARY KEY AUTO_INCREMENT COMMENT ' Set Primary Key Self Increase ',
 gname VARCHAR(200) COMMENT ' Column Notes '
 ) COMMENT=' Table Notes ';

2 Modify existing columns with explanations


alter table test_data modify column test_desc int comment 'xxxx';

3 Modify existing tables with explanations


ALTER TABLE test_data COMMENT=' Store test case related data '; 

4 View the structure of the entire table


SHOW CREATE TABLE test_data;
# View comments for tables 
SELECT table_name,table_comment FROM information_schema.tables WHERE table_schema = 'test' AND table_name ='test_data';

5 View column explanations


SHOW FULL COLUMNS FROM test_data;
SELECT column_name, column_comment FROM information_schema.columns WHERE table_schema ='test' AND table_name = 'test_data';

Related articles: