大家好,又見面了,我是全棧君。
查詢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 指具體的表名
如查詢work_ad資料庫中是否存在包含”user”關鍵字的資料表
select table_name from information_schema.tables where table_schema = 'work_ad' and table_type='base table' and table_name like '%user%';
複制
如果本身是在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;
複制
mysql中查詢到包含該字段的所有表名
SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME='字段名'
複制
如:查詢包含status 字段的資料表名
select table_name from information_schema.columns where column_name='status';
複制
釋出者:全棧程式員棧長,轉載請注明出處:https://javaforall.cn/112142.html原文連結:https://javaforall.cn