mysql 查詢表,mysql數據庫如何快速獲得庫中無主鍵的表?
獲取數據庫中除系統庫之外所有無主鍵的表sql如下:
SELECT
table_schema,
table_name
FROM
information_schema. TABLES
WHERE
(table_schema, table_name) NOT IN (
SELECT DISTINCT
table_schema, table_name
FROM
information_schema. COLUMNS
WHERE
COLUMN_KEY = 'PRI'
)
AND table_schema NOT IN (
'sys',
'mysql',
'information_schema',
'performance_schema'
);