Mysql中返回一个数据库的所有表名,列名数据类型备注

很文博客hinven.com 数据库评论328字数 772阅读模式
广告也精彩
在Mysql中怎样返回一个数据库的所有表名,列名数据类型备注

desc 表名;
show columns from 表名;
describe 表名;
show create table 表名;use information_schema
select * from columns where table_name='表名';

顺便记下:
show databases;
也可以这样文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/46495.html

use information_schema文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/46495.html

select table_schema,table_name from tables where table_schema='数据库名'文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/46495.html

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);文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/46495.html

若发现索引的逻辑不对,还需要再加一个字段进去,执行
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,再重做上一步才行文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/46495.html

获取列名数据类型备注
SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT FROM information_schema.columns WHERE table_name = ?文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/46495.html

文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/46495.html

工具:作品在线观看

女优:最新作品观看

中文:国语在线观看

weinxin
我的微信
扫一扫更精彩
大家的支持是我更新的动力!!!
 
广告也精彩
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证