MySQL关于查找模式对象的语句
发布时间:2022-08-02 12:23:24 所属栏目:云计算 来源:互联网
导读:在日常工作中,搜索特定的数据库对象,是最常见的一个工作,下面分享几个关于mysql模式查找的语句。 1. 在 MySQL 数据库中查找名称中包含数字的表 复制 select table_schema as database_name, table_name from information_schema.tables where table_type
在日常工作中,搜索特定的数据库对象,是最常见的一个工作,下面分享几个关于mysql模式查找的语句。 1. 在 MySQL 数据库中查找名称中包含数字的表 复制 select table_schema as database_name, table_name from information_schema.tables where table_type = 'BASE TABLE' and table_name rlike ('[0-9]') order by table_schema, table_name; 1. 2. 3. 4. 5. 6. 7. 说明: database_name - 找到表的数据库(模式)的名称 table_name - 找到的表的名称 DBA技术分享(十二)- Mysql关于查找模式对象的语句 2. 在 MySQL 数据库中查找关于特定列名的表 复制 select tab.table_schema as database_name, tab.table_name from information_schema.tables as tab inner join information_schema.columns as col on col.table_schema = tab.table_schema and col.table_name = tab.table_name where tab.table_type = 'BASE TABLE' and column_name = 'idcity' order by tab.table_schema, tab.table_name; 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 说明: database_name - 找到表的数据库(模式)的名称 table_name - 找到的表的名称 DBA技术分享(十二)- Mysql关于查找模式对象的语句 3. 在 MySQL 数据库中查找没有特定名称的列的表 复制 select tab.table_schema as database_name, tab.table_name from information_schema.tables tab left join information_schema.columns col on tab.table_schema = col.table_schema and tab.table_name = col.table_name and col.column_name = 'id' -- put column name here where tab.table_schema not in ('information_schema', 'mysql', 'performance_schema', 'sys') and tab.table_type = 'BASE TABLE' and col.column_name is null order by tab.table_schema, tab.table_name; 说明: database_name - 找到的表的数据库(模式)名称 table_name - 找到的表的名称 (编辑:肇庆站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |