在多个表中显示 SQL 个约束条件

Show SQL constraints in multiple tables

假设我有这 3 个约束:

ALTER TABLE actor ADD CONSTRAINT PK_ACTORID PRIMARY KEY (actor_id);
ALTER TABLE film ADD CONSTRAINT PK_FILMID PRIMARY KEY (film_id);
ALTER TABLE film_actor ADD CONSTRAINT FK_FILMID1 FOREIGN KEY (film_id) REFERENCES film;

我需要写 sql 来显示这些 table 约束:

-- Check which constraints added in ACTOR table
SELECT OWNER, CONSTRAINT_NAME, TABLE_NAME, SEARCH_CONDITION, INDEX_NAME 
FROM USER_CONSTRAINTS
WHERE TABLE_NAME = 'ACTOR';

-- Check which constraints added in FILM_ACTOR table
SELECT OWNER, CONSTRAINT_NAME, TABLE_NAME, SEARCH_CONDITION, INDEX_NAME 
FROM USER_CONSTRAINTS
WHERE TABLE_NAME = 'FILM_ACTOR';

最后的结果是这样的:

我的问题是,如何将我写的两个 sql 语句合并为 1 sql 并格式化显示的结果。

更改您的 where 语句是否有效?

像这样:

SELECT OWNER, CONSTRAINT_NAME, TABLE_NAME, SEARCH_CONDITION, INDEX_NAME 
FROM USER_CONSTRAINTS
WHERE TABLE_NAME = 'ACTOR' or table_name = 'film' or table_name ='film_actor';