Mysql表结构查看命令

来源:岁月联盟 编辑:猪头三 时间:2010-11-20

如果需要查看Mysql表结构,应该使用什么命令呢?下面就为您详细介绍查看Mysql表结构的命令,如果您在Mysql表机构方面遇到过类似的问题,不妨一看。

查看Mysql表结构的命令,如下:

desc 表名;
show columns from 表名;
describe 表名;
show create table 表名;

use information_schema
select * from columns where table_name='表名';

顺便记下:
show databases;
use 数据库名;
show tables;

原有一unique索引AK_PAS_Name(PAC_Name)在表tb_webparamcounter中,
执行以下sql修改索引
alter table tb_webparamcounter drop index AK_PAS_Name;
alter table tb_webparamcounter add UNIQUE AK_PAS_Name(PC_ID,PAC_Name);

若发现索引的逻辑不对,还需要再加一个字段进去,执行
alter table tb_webparamcounter drop index AK_PAS_Name;
alter table tb_webparamcounter add UNIQUE AK_PAS_Name(PC_ID,PAC_Name,PAC_Value);
注意:这时的PC_ID,PAC_Name,PAC_Value三个字段不是FOREIGN KEY
否则必需先drop FOREIGN KEY,再重做上一步才行

顺便提下oracle
select * from v$database;
select * from all_users;
select * from user_tables;