沙滩星空的博客沙滩星空的博客

MySQL 查看表结构简单命令

information_schema 数据库跟 performance_schema 一样,都是 MySQL 自带的信息数据库。其中 performance_schema 用于性能分析,而 information_schema 用于存储数据库元数据(关于数据的数据),例如数据库名、表名、列的数据类型、访问权限等。

显示表结构,字段类型,主键,是否为空等属性,但不显示外键。

desc table_name

查询表中列的注释信息

select * from information_schema.columns where table_schema = 'db' and table_name = 'tablename' ;

只查询列名和注释

select column_name, column_comment from information_schema.columns where table_schema ='db' and table_name = 'tablename' ;

查看表的注释

select table_name,table_comment from information_schema.tables where table_schema = 'db' and table_name ='tablename'

修改表结构
ALTER TABLE competitor_goods ADD sku_id bigint(20) unsigned DEFAULT NULL COMMENT '商品销售码';
ALTER TABLE sd_game_score_order MODIFY diamond FLOAT(14,2) DEFAULT 0.00;


MySQL 查看表结构简单命令 https://www.cnblogs.com/gide/p/6179975.html
MySQL 中的 information_schema 数据库 https://blog.csdn.net/kikajack/article/details/80065753

未经允许不得转载:沙滩星空的博客 » MySQL 查看表结构简单命令

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址