查询mysql表结构命令
来源:互联网 发布:超级神基因优化液txt 编辑:程序博客网 时间:2024/05/16 17:11
方法1:
desc 表名;
方法2:
show columns from 表名;
方法3:
describe 表名;
方法4:
show create table 表名;# 此命令是实时反映当前表结构,不是说后期改了表结构了,它就不变的show create table alert;CREATE TABLE `alert` ( `id` int(11) NOT NULL AUTO_INCREMENT, `model` varchar(20) NOT NULL DEFAULT '', `stat` int(11) NOT NULL DEFAULT '0', `level` int(11) NOT NULL DEFAULT '0', `msg` varchar(1000) NOT NULL DEFAULT '', `target` varchar(50) NOT NULL DEFAULT '', `create_time` datetime NOT NULL, `end_time` datetime NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1# 我加一个字段alter table `alert` Add column ss int not null default 0;show create table alert;CREATE TABLE `alert` ( `id` int(11) NOT NULL AUTO_INCREMENT, `model` varchar(20) NOT NULL DEFAULT '', `stat` int(11) NOT NULL DEFAULT '0', `level` int(11) NOT NULL DEFAULT '0', `msg` varchar(1000) NOT NULL DEFAULT '', `target` varchar(50) NOT NULL DEFAULT '', `create_time` datetime NOT NULL, `end_time` datetime NOT NULL, `ss` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1# 发现多了‘ss’字段的说明了把
还有一种情况是以上方法都不适用的:数据库里的表名是数据库命令的关键字。
desc databases;# 表名叫‘databases’,错误信息如下,这时候想查表结构,要用方法5ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'databases' at line 1
方法5:
select * from information_schema.columns where table_schema = '库名' and table_name = '表名';
方法6:
使用第三方可视化工具,网上很多
阅读全文
0 0
- 查询mysql表结构命令
- MySQL 表结构查询
- mysql 查询表结构
- mysql表结构查询
- mysql表结构查询
- MySql查询表结构
- 查询mysql的表结构
- 如何查询mysql表结构
- Mysql查询数据库表结构
- mysql 查询表结构SQL
- mysql查看表结构命令
- mysql查看表结构命令
- mysql查看表结构命令
- mysql查看表结构命令
- mysql查看表结构命令
- mysql查看表结构命令
- mysql查看表结构命令
- mysql查看表结构命令
- BZOJ 4569: [Scoi2016]萌萌哒
- Socket.io入门引渡
- 【C++11新特性】 C++11智能指针之shared_ptr
- rank,dense_rank,row_number使用和区别
- 23种设计模式汇总整理
- 查询mysql表结构命令
- [S3-E435]深度挖掘 Object 对象的使用
- 文件上传功能测试的测试点
- python 进阶之属性函数property
- lua-binding配置安卓。
- 进程间通信-管道
- ssh框架下载本地文件
- Jmeter属性和变量
- QString::section