Reference connection is not on the whole Baidu is the same. I have a comment about
# Comment comment; comments; criticism; Description
1, the new table and add the tables and fields of the annotations.
Create Table T_USER (
ID the INT (. 19) Primary Key AUTO_INCREMENT Comment 'master key',
NAME VARCHAR (300) Comment 'name',
CREATE_TIME DATE Comment 'Created'
) Comment = ' user information table ';
Add # field inherent field rearmost COMMENT Note, outside the parentheses by COMMENT = '' to add to the Notes to Table
2, the comment modify the table / field.
ALTER Table T_USER Comment = 'table annotation information (user information table) modified';
alter table t_user modify column id int comment ' primary key ID';
- Note: the field names and types according to the write line
. 3, details query the database for all tables (including comment table)
use INFORMATION_SCHEMA;
SELECT * from tABLES WHERE the TABLE_SCHEMA = 'database where your tables';
- a query of a table
use information_schema;
the SELECT * from the wHERE TABLE_SCHEMA tABLES = 'database tables where you' and TABLE_NAME = 'your table';
mysql> SELECT * FROM TABLES WHERE table_schema='test' AND table_name='test1'\G *************************** 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: test TABLE_NAME: test1 TABLE_TYPE: BASE TABLE ENGINE: InnoDB VERSION: 10 ROW_FORMAT: Dynamic TABLE_ROWS: 0 AVG_ROW_LENGTH: 0 DATA_LENGTH: 16384 MAX_DATA_LENGTH: 0 INDEX_LENGTH: 0 DATA_FREE: 0 AUTO_INCREMENT: NULL CREATE_TIME: 2020-03-26 22:47:59 UPDATE_TIME: NULL CHECK_TIME: NULL TABLE_COLLATION: utf8_general_ci CHECKSUM: NULL CREATE_OPTIONS: TABLE_COMMENT: Table I explain 1 row in set (0.00 sec)
4, for more information query a table (including field notes, field name, type, etc.).
Use information_schema;
the SELECT * from information_schema.columns the WHERE table_schema = 'database tables where you' and table_name = 'your table' ;
mysql> mysql> SELECT * FROM COLUMNS WHERE table_schema='test' AND table_name='test1'\G *************************** 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: test TABLE_NAME: test1 COLUMN_NAME: tt ORDINAL_POSITION: 1 COLUMN_DEFAULT: NULL IS_NULLABLE: YES DATA_TYPE: int CHARACTER_MAXIMUM_LENGTH: NULL CHARACTER_OCTET_LENGTH: NULL NUMERIC_PRECISION: 10 NUMERIC_SCALE: 0 DATETIME_PRECISION: NULL CHARACTER_SET_NAME: NULL COLLATION_NAME: NULL COLUMN_TYPE: int(11) COLUMN_KEY: EXTRA: PRIVILEGES: select,insert,update,references COLUMN_COMMENT: 我是解释 GENERATION_EXPRESSION: 1 row in set (0.00 sec) mysql>
Note: There is another way:
# View the construction of the table statement, you can see a table with the comments field Comment
show create table table_name;
MySQL> SHOW the CREATE TABLE test1 \ G *************************** 1. Row ************ *************** the Table: test1 the Create the Table: the CREATE TABLE `test1` ( ` tt` int (11) the DEFAULT NULL the COMMENT 'I explain' ) ENGINE = InnoDB the DEFAULT CHARSET = utf8 COMMENT = 'table I explain' 1 Row in the SET (0.00 sec) MySQL>
# SHOW ways to view your comment field
show full columns from table name;
mysql> SHOW FULL COLUMNS FROM test1; +-------+---------+-----------+------+-----+---------+-------+---------------------------------+--------------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-------+---------+-----------+------+-----+---------+-------+---------------------------------+--------------+ | tt | int(11) | NULL | YES | | NULL | | select,insert,update,references | 我是解释 | +-------+---------+-----------+------+-----+---------+-------+---------------------------------+--------------+ 1 row in set (0.00 sec) mysql>
So Overall, we want to see if the information tables and fields, the best view of the statement by the construction of the table.
Is SHOW CREATE TABLE xxx, the most convenient
# Comment comment; comments; criticism; Description
1, the new table and add the tables and fields of the annotations.
Create Table T_USER (
ID the INT (. 19) Primary Key AUTO_INCREMENT Comment 'master key',
NAME VARCHAR (300) Comment 'name',
CREATE_TIME DATE Comment 'Created'
) Comment = ' user information table ';
Add # field inherent field rearmost COMMENT Note, outside the parentheses by COMMENT = '' to add to the Notes to Table
2, the comment modify the table / field.
ALTER Table T_USER Comment = 'table annotation information (user information table) modified';
alter table t_user modify column id int comment ' primary key ID';
- Note: the field names and types according to the write line
. 3, details query the database for all tables (including comment table)
use INFORMATION_SCHEMA;
SELECT * from tABLES WHERE the TABLE_SCHEMA = 'database where your tables';
- a query of a table
use information_schema;
the SELECT * from the wHERE TABLE_SCHEMA tABLES = 'database tables where you' and TABLE_NAME = 'your table';
mysql> SELECT * FROM TABLES WHERE table_schema='test' AND table_name='test1'\G *************************** 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: test TABLE_NAME: test1 TABLE_TYPE: BASE TABLE ENGINE: InnoDB VERSION: 10 ROW_FORMAT: Dynamic TABLE_ROWS: 0 AVG_ROW_LENGTH: 0 DATA_LENGTH: 16384 MAX_DATA_LENGTH: 0 INDEX_LENGTH: 0 DATA_FREE: 0 AUTO_INCREMENT: NULL CREATE_TIME: 2020-03-26 22:47:59 UPDATE_TIME: NULL CHECK_TIME: NULL TABLE_COLLATION: utf8_general_ci CHECKSUM: NULL CREATE_OPTIONS: CREATE_OPTIONS: TABLE_COMMENT: Table I explain 1 row in set (0.00 sec)
4, for more information query a table (including field notes, field name, type, etc.).
Use information_schema;
the SELECT * from information_schema.columns the WHERE table_schema = 'database tables where you' and table_name = 'your table' ;
mysql> mysql> SELECT * FROM COLUMNS WHERE table_schema='test' AND table_name='test1'\G *************************** 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: test TABLE_NAME: test1 COLUMN_NAME: tt ORDINAL_POSITION: 1 COLUMN_DEFAULT: NULL IS_NULLABLE: YES DATA_TYPE: int CHARACTER_MAXIMUM_LENGTH: NULL CHARACTER_OCTET_LENGTH: NULL NUMERIC_PRECISION: 10 NUMERIC_SCALE: 0 DATETIME_PRECISION: NULL CHARACTER_SET_NAME: NULL COLLATION_NAME: NULL COLUMN_TYPE: int(11) COLUMN_KEY: EXTRA: PRIVILEGES: select,insert,update,references COLUMN_COMMENT: 我是解释 GENERATION_EXPRESSION: 1 row in set (0.00 sec) mysql>
Note: There is another way:
# View the construction of the table statement, you can see a table with the comments field Comment
show create table table_name;
MySQL> SHOW the CREATE TABLE test1 \ G *************************** 1. Row ************ *************** the Table: test1 the Create the Table: the CREATE TABLE `test1` ( ` tt` int (11) the DEFAULT NULL the COMMENT 'I explain' ) ENGINE = InnoDB the DEFAULT CHARSET = utf8 COMMENT = 'table I explain' 1 Row in the SET (0.00 sec) MySQL>
# SHOW ways to view your comment field
show full columns from table name;
mysql> SHOW FULL COLUMNS FROM test1; +-------+---------+-----------+------+-----+---------+-------+---------------------------------+--------------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-------+---------+-----------+------+-----+---------+-------+---------------------------------+--------------+ | tt | int(11) | NULL | YES | | NULL | | select,insert,update,references | 我是解释 | +-------+---------+-----------+------+-----+---------+-------+---------------------------------+--------------+ 1 row in set (0.00 sec) mysql>
So Overall, we want to see if the information tables and fields, the best view of the statement by the construction of the table.
Is SHOW CREATE TABLE xxx, the most convenient