MySQL查询表结构命令
参考网址:https://www.cnblogs.com/zhangyuhang3/p/6873895.html
一、简单描述表结构,字段类型
desc tabl_name;
desc tabl_name;
显示表结构,字段类型,主键,是否为空等属性,但不显示外键。如下图所示:

五、查看表生成的DDL
查看建表语句:
show create table table_name;
这个命令虽然显示起来不是太容易看, 这个不是问题可以用\G来结尾,使得结果容易阅读;该命令把创建表的DDL显示出来,于是表结构、类型,外键,备注全部显示出来了。
我比较喜欢这个命令:输入简单,显示结果全面。
补充一些可能用到的命令:
建表命令:
CREATE TABLE `t_sold_order` (
`id` INT (11) NOT NULL AUTO_INCREMENT,
`dt` date DEFAULT NULL COMMENT '日期',
`hour` TINYINT (2) DEFAULT '0' COMMENT '小时',
`hour_order` INT (11) DEFAULT '0' COMMENT '小时订单数',
`total_order` INT (11) DEFAULT '0' COMMENT '总的订单数',
`prediction` INT (11) DEFAULT '0' COMMENT '预测订单数',
PRIMARY KEY (`id`),
UNIQUE KEY `dt_hour` (`dt`, `hour`)
) ENGINE = INNODB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8 COMMENT = '实时订单数'
表操作命令:
复制表结构:create table table1 like table;
复制数据:insert into table1 select * from table
机器授权:
grant select on *.* to 'reader'@'%' identified by '123456' WITH GRANT OPTION
flush privileges
查询数据直接插入
insert into t_visual_user_domain(`user_id`,`domain`,`group`) select id,'www.baidu.com' as domain,`group` from t_visual_user;
修改表结构
alter table competitor_goods add sku_id bigint(20) unsigned DEFAULT NULL COMMENT '商品销售码';
MySQL查询表结构命令的更多相关文章
- MySQL查询表结构的SQL小结
mysql查看表结构命令,如下: desc 表名; show columns from 表名; describe 表名; show create table 表名; 示例: use testDB; # ...
- MYSQL查询表结构
mysql查看表结构命令,如下: desc 表名;show columns from 表名;describe 表名;show create table 表名; use information_sche ...
- SQL Server里查询表结构命令
现提供两条命令查询表结构: 1.sp_help table_name; 如: [sql] sp_help Student; 2.sp_columns table_name; ...
- mysql 查询表结构 查询索引
首先进入到mysql里 show databases; 选择数据库 use xxxcms; 查询数据库下的表结构 show create table 表名; 这样看着不太好可以后面加\G show c ...
- MySQL查询表结构的SQL语句
desc 数据库.表名; eg: desc mysql.user;
- mysql 查询表结构
use information_schema; select column_name, column_type, data_type, is_nullable, column_comment from ...
- MySql 查询表结构信息
select Column_name as 列名,is_nullable as 是否可为空,data_type as 数据类型,column_default as 默认值,case when colu ...
- mysql查看表结构命令
mysql查看表结构命令 mysql查看表结构命令,如下: desc 表名;show columns from 表名;describe 表名;show create table 表名; use inf ...
- 查看表结构命令(mysql和oracle)
MySQL查看表结构SQL语句 = mysql查看表结构命令,如下: desc 表名; show columns from 表名; describe 表名; show create table 表名; ...
随机推荐
- oracle 数据库io 异常,错误代码17002 解决办法
数据库使用一个月了,突然挂掉:错误代码17002 io异常:read timeout 解决: 1.登陆sql命令窗口 [oracle@hostname ~]$ sqlplus /nolog SQL*P ...
- 【MySQL】死锁问题分析
1.MySQL常用存储引擎的锁机制: MyISAM和MEMORY采用表级锁(table-level locking) BDB采用页面锁(page-level locking)或表级锁,默认为页面锁 ...
- 22个值得收藏的Android开源代码——cool
转自http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/1020/1808.html 本文介绍了android开发者中比较热门的开源代 ...
- set_magic_quotes_runtime set_magic_quotes_gpc
set_magic_quotes_runtime(0); 可以修改php.ini中 magic_quotes_runtime boolean的设置 当你的数据中有一些\"'这样的字符要写入到 ...
- SQL语句 删除表user 中字段name 内容重复的记录,
public class T01 { public static void main(String[] args) { int j=4; j=j+=j-=j*=j; System.out.printl ...
- django后台admin管理布局
在model模块里设置 class pc_info(models.Model): ip = models.CharField(max_length=64) sn = models.CharField( ...
- 解决rpm conflicts with file from package的两个方法
1.卸载掉冲突的文件,安装新的文件.如果由于由于依赖关系导致要卸载很多软件,那可以优先考虑下一个方法. 2.安装的时候增加–replacefiles参数,例如 rpm -ivh xxx.rpm –re ...
- B - Avoiding a disaster
Description Percy likes to be punctual. So much so that he always keeps three watches with him, so t ...
- EBS 定义显示总帐快码设置
自定义一个功能如下,挂到菜单上就可以了功能 用户功能名 表单 参数GL_GLXDQMLK(自定义) 总帐代码列表 定义代码 VIEW_APPLICATION="SQLGL" HEL ...
- 如何利用JUnit开展一个简单的单元测试(测试控制台输出是否正确)
待测类(CreateString)如下: public class CreateString { public void createString() { //Output the following ...