在MySQL中,要查詢所有數(shù)據(jù)庫(kù)的表,可以使用以下命令:
SELECT table_schema AS 'Database', table_name
FROM information_schema.tables
WHERE table_schema NOT IN ('mysql', 'information_schema', 'performance_schema');
這條命令會(huì)從information_schema.tables
表中獲取所有非系統(tǒng)自帶的數(shù)據(jù)庫(kù)(如’mysql’,‘information_schema’,‘performance_schema’)的表名。information_schema
是一個(gè)包含所有MySQL數(shù)據(jù)庫(kù)元數(shù)據(jù)的模式。
執(zhí)行此查詢后,您將獲得一個(gè)結(jié)果集,其中包含兩列:‘Database’和’table_name’,分別表示數(shù)據(jù)庫(kù)名稱和表名稱。