大家好,又见面了,我是全栈君。
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’;
select * from systables where tabname like 'saa%'
此法只对Informix数据库有用
select column_name from information_schema.columns where table_schema='csdb' and table_name='xxx'
select count(1) from information_schema.tables where table_schema = 'test' and table_name = 'd_ad';
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