MySQL中 如何查詢表名中包含某字段的表


 

 

查詢tablename 數據庫中 以"_copy" 結尾的表

select table_name from information_schema.tables where table_schema='tablename' and table_type='base table' and table_name like '%_copy';

information_schema 是MySQL系統自帶的數據庫,提供了對數據庫元數據的訪問
information_schema.tables 指數據庫中的表(information_schema.columns 指列)
table_schema 指數據庫的名稱
table_type 指是表的類型(base table 指基本表,不包含系統表)
table_name 指具體的表名

如果本身是在tablename 這個庫里新建的查詢,可以去掉 table_schema='tablename ' 這一句
select table_name from information_schema.tables where table_type='base table' and table_name like '%_copy';

 

在Informix數據庫中,如何查詢表名中包含某字段的表

select * from systables where tabname like 'saa%'
此法只對Informix數據庫有用

 

查詢指定數據庫中指定表的所有字段名column_name

select column_name from information_schema.columns where table_schema='csdb' and table_name='xxx'

 

 檢查數據庫'test'中的某一個表'd_ad'是否存在

select count(1) from information_schema.tables where table_schema = 'test' and table_name = 'd_ad';

 

如何查詢mysql數據庫中有多少張表

select count(*) TABLES, table_schema from information_schema.tables where table_schema = 'test' group by table_schema;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM