Mysql中返回一個數(shù)據庫的所有表名,列名數(shù)據類型備注
更新時間:2010年04月28日 22:52:02 作者:
在Mysql中怎樣返回一個數(shù)據庫的所有表名,列名數(shù)據類型備注
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='數(shù)據庫名'
use 數(shù)據庫名;
show tables;
原有一unique索引AK_PAS_Name(PAC_Name)在表tb_webparamcounter中,
執(zhí)行以下sql修改索引
alter table tb_webparamcounter drop index AK_PAS_Name;
alter table tb_webparamcounter add UNIQUE AK_PAS_Name(PC_ID,PAC_Name);
若發(fā)現(xiàn)索引的邏輯不對,還需要再加一個字段進去,執(zhí)行
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,再重做上一步才行
獲取列名數(shù)據類型備注
SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT FROM information_schema.columns WHERE table_name = ?
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='數(shù)據庫名'
use 數(shù)據庫名;
show tables;
原有一unique索引AK_PAS_Name(PAC_Name)在表tb_webparamcounter中,
執(zhí)行以下sql修改索引
alter table tb_webparamcounter drop index AK_PAS_Name;
alter table tb_webparamcounter add UNIQUE AK_PAS_Name(PC_ID,PAC_Name);
若發(fā)現(xiàn)索引的邏輯不對,還需要再加一個字段進去,執(zhí)行
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,再重做上一步才行
獲取列名數(shù)據類型備注
SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT FROM information_schema.columns WHERE table_name = ?
相關文章
MyBatis攔截器實現(xiàn)分頁功能的實現(xiàn)方法
這篇文章主要介紹了MyBatis攔截器實現(xiàn)分頁功能的實現(xiàn)方法的相關資料,希望通過本文大家能夠實現(xiàn)這樣的方法,需要的朋友可以參考下2017-10-10MySQL報錯Failed to open the referenced&nbs
在數(shù)據庫操作中,嘗試刪除外鍵約束表'master_role'時遇到錯誤碼3730,因其被'user_role'表中的外鍵'fk_user_role'引用,解決方法包括關閉外鍵檢查和刪除外鍵,阿里巴巴開發(fā)手冊和知乎回答指出,外鍵雖能維護數(shù)據一致性2024-11-11Ubuntu下啟動、停止、重啟MySQL,查看錯誤日志命令大全
這篇文章主要介紹了Ubuntu下啟動、停止、重啟MySQL,查看錯誤日志命令大全,需要的朋友可以參考下2014-06-06MySQL中SQL分頁查詢的幾種實現(xiàn)方法及優(yōu)缺點
這篇文章主要介紹了MySQL中SQL分頁查詢的幾種實現(xiàn)方法及優(yōu)缺點, 分頁查詢就是在滿足條件的一堆有序數(shù)據中截取當前所需要展示的那部分。對此感興趣的可以來了解一下2020-07-07mysql 8.0.15 winx64壓縮包安裝配置方法圖文教程
這篇文章主要為大家詳細介紹了mysql 8.0.15 winx64壓縮包安裝配置方法圖文教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-05-05