MySQL 查看表结构简单命令
一、简单描述表结构,字段类型
desc table_name;
显示表结构,字段类型,主键,是否为空等属性,但不显示外键。
例如:desc t_user
二、查询表中列的注释信息
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'
五、查看表生成的DDL
show create table table_name;
表操作命令:
复制表结构:create table tableName1 like tableName2;
复制数据:insert into tableName1 select * from tableName1
访问授权:
grant select on *.* to 'read'@'%' identified by '12345678' WITH GRANT OPTION
flush privileges
查询数据直接插入
insert into t_user_domain(`user_id`,`domain`,`group`) select id,'www.baidu.com' as domain,`group` from t_visual_user;
修改表结构
alter table t_goods add sku_id bigint(20) unsigned DEFAULT NULL COMMENT '商品销售码';
上一篇: nginx(4):nginx负载均衡