您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2025/5/9 7:05:09发布14次查看
在mysql中怎样返回一个数据库的所有表名,列名数据类型备注
desc 表名;
show columns from 表名;
describe 表名;
show create table 表名;
use information_schema
select * from columns where table_name='表名';
顺便记下:
show databases;
也可以这样
use information_schema
select table_schema,table_name from tables where table_schema='数据库名'
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,再重做上一步才行
获取列名数据类型备注
select column_name, data_type, column_comment from information_schema.columns where table_name = ?
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product