mysql查詢表和字段的注釋


1,新建表以及添加表和字段的注釋.
   create table t_user(
        ID INT(19) primary key auto_increment  comment '主鍵',
        NAME VARCHAR(300) comment '姓名',
        CREATE_TIME date comment '創建時間'
    )comment  = '用戶信息表';

2,修改表/字段的注釋.
     alter table t_user comment  = '修改后的表注釋信息(用戶信息表)';
    alter table t_user modify column id int comment '主鍵ID';
   --注意:字段名和字段類型照寫就行

3,查詢數據庫所有表的詳細信息(包括表的注釋).
use information_schema;
select * from TABLES where TABLE_SCHEMA='my_db';
--查詢某一張表的
use information_schema;
select * from TABLES where TABLE_SCHEMA='my_db' and TABLE_NAME= 'auth_user';

4,查詢一張表的詳細信息(包括字段注釋,字段名稱,類型等).
use information_schema;
select * from information_schema.columns where table_schema ='my_db'  and table_name = 'auth_user';

注:還有一種方式:

show create table table_name;
use my_db;
show full columns from auth_user;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM