您可以从information_schema.columns表中提取此信息
select distinct table_name
from information_schema.columns
where table_schema = 'DATABASENAME'
and table_name not in (select table_name
from information_schema.columns
where table_schema = 'DATABASENAME'
and column_key = 'PRI'
and data_type = 'int'
and extra = 'auto_increment')
Run Code Online (Sandbox Code Playgroud)
这将查找具有auto_increment列的一个数据库中的所有表,然后返回其余表.这也正确地检测具有复合键的表.
| 归档时间: |
|
| 查看次数: |
1859 次 |
| 最近记录: |