I. Simple description table structure, field type
Desc Tabl_name;
Displays the table structure, the field type, the primary key, whether it is empty, and so on, but does not display foreign keys.
For example: DESC table_name
Second, the query table column of the comment information
SELECT * FROM Information_schema.columns
where Table_schema = ' db ' #表所在数据库
and table_name = ' tablename '; #你要查的表
For example:
can automatically select the information you need
Querying column names and comments only
Select column_name, column_comment from information_schema.columns where table_schema = ' db ' and table_name = ' tablename ';
For example:
Iv. #查看表的注释
Select Table_name,table_comment from information_schema.tables where table_schema = ' db ' and table_name = ' tablename '
For example:
V. View the DDL generated by the table
Show CREATE TABLE table_name;
For example:
Although this command is not very easy to see, this is not a problem can be \g to the end, making the results easy to read; The command displays the DDL that created the table, so the table structure, type, foreign key, and comments are all displayed.
I prefer this command: the input is simple and the results are comprehensive.
Add some of the commands you might use:
Build Table command:
CREATE TABLE ' T_sold_order ' (
' id ' int (one) not NULL auto_increment,
The ' DT ' date DEFAULT NULL COMMENT ' Date ',
' Hour ' tinyint (2) DEFAULT ' 0 ' COMMENT ' hours ',
' Hour_order ' int (one) DEFAULT ' 0 ' COMMENT ' hour order number ',
' Total_order ' int (one) DEFAULT ' 0 ' COMMENT ' total number of orders ',
' Prediction ' int (one) DEFAULT ' 0 ' COMMENT ' forecast order number ',
PRIMARY KEY (' id '),
UNIQUE KEY ' dt_hour ' (' dt ', ' hour ')
) Engine=innodb auto_increment=1 DEFAULT Charset=utf8 comment= ' Live Order Count '
Table Operation Commands:
Duplicate table structure: CREATE TABLE table1 like table;
Copy data: INSERT INTO table1 select * FROM table
Machine Authorization:
Grant SELECT On * * to ' reader ' @ '% ' identified by ' 123456 ' with GRANT OPTION
Flush Privileges
Query data is inserted directly
Insert into T_visual_user_domain (' user_id ', ' domain ', ' group ') Select ID, ' www.baidu.com ' as domain, ' group ' from t_visual _user;
Modify Table Structure
ALTER TABLE competitor_goods add sku_id bigint unsigned DEFAULT NULL COMMENT ' Commodity Sales Code ';
MySQL View table Structure Simple command