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
3. 查看方法:
方法1:show full fields from '表名称'; //把所有信息都输出
方法2:show create table gbox;
修改表的comment项(如修改gbox表):
alter table gbox COMMENT = 'new information';
修改数据库表的某列(name)的COMMENT:
alter table gbox change COLUMN name name datatype COMMENT 'new column commen