我想在phpmyadmin / mysql中调试我的数据库。哪个是查看数据库中所有外键和索引的最佳命令?
还有办法查看可能的索引和外键错误吗?
答案 0 :(得分:0)
此代码段将显示所有外键:
SELECT concat(table_name, '.', column_name) as 'foreign key',
concat(referenced_table_name, '.', referenced_column_name) as 'references'
FROM INFORMATION_SCHEMA.key_column_usage
WHERE referenced_table_name is not null;
另一个显示所有索引:
SELECT DISTINCT TABLE_NAME, INDEX_NAME
FROM INFORMATION_SCHEMA.STATISTICS;