我尝试禁用附加到表中列的约束
ALTER TABLE
ADV_TEST_COURSE_CREDIT
DISABLE constraint
name = (SELECT
constraint_name
from
user_constraints natural join
user_cons_columns
where
table_name = 'ADV_TEST_COURSE_CREDIT' AND
column_name = 'SEQUENCE_NUMBER' AND
constraint_type = 'C');
我尝试上面的陈述。它不起作用。关于如何使其发挥作用的任何想法。
表ADV_TEST_COURSE_CREDIT
存在于dev,UAT,Production中,因此约束名称不同,但它全部附加了一个名为SEQUENCE_NUMBER
的列
答案 0 :(得分:2)
你需要动态的sql和一些plsql:
declare name varchar2(200);
begin
SELECT
constraint_name
into name
from
user_constraints natural join
user_cons_columns
where
table_name = 'ADV_TEST_COURSE_CREDIT' AND
column_name = 'SEQUENCE_NUMBER' AND
constraint_type = 'C');
execute immediate 'ALTER TABLE ADV_TEST_COURSE_CREDIT DISABLE CONSTRAINT :1' using name;
end;