MySQL建表语句+添加注释

1.建表+注释

CREATE TABLE student(
  id INT PRIMARY KEY AUTO_INCREMENT COMMENT '学号',
  name VARCHAR(200) COMMENT '姓名',
  age    int COMMENT '年龄'
) COMMENT='学生信息'

2.修改注释

修改表注释-ALTER TABLE student COMMENT '学生表';
                    
修改列注释-ALTER TABLE student MODIFY COLUMN name VARCHAR(100) COMMENT '姓名';

SELECT table_name,table_comment FROM information_schema.tables  WHERE table_schema = '所在的db' AND table_name ='表名groups'
SHOW FULL COLUMNS FROM groups
-- 这个可以按条件的去搜索某名字或某数据类型的列的信息:例如
SHOW FULL COLUMNS FROM tableName WHERE FIELD = 'add_time' OR TYPE LIKE '%date%' -- 查看tableName表中列名是add_time的或类型是date的列
SELECT  column_name, column_comment FROM information_schema.columns WHERE table_schema ='db'  AND table_name = 'groups'
SHOW  CREATE TABLE communication_group

 

    原文作者:mysql
    原文地址: https://www.cnblogs.com/qinxu/p/9291115.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞