如何连接两个查询以获取表元数据?
select constraint_type
from information_schema.table_constraints
where constraint_schema = 'test'
and table_name='user';
select table_name,column_name,constraint_name,referenced_table_name,referenced_column_name from
information_schema.key_column_usage
where table_schema= 'test'
and table_name = 'user';
答案 0 :(得分:0)
在架构和名称字段上尝试内部联接,如下所示:
SELECT constraint_type, table_constraints.table_name,column_name,constraint_name,referenced_table_name,referenced_column_name
FROM information_schema.table_constraints INNER JOIN information_schema.key_column_usage
ON table_constraints.table_name=information_schema.table_name
AND table_schema = constraint_schema;