Is there a way in oracle to disable / enable an unnamed restriction?

I want to disable NOT NULL constraints in a table to insert data for a test, but I cannot find a way to disable unnamed constraints.

I found enough information to disable named constraints, but I could not find an example to disable an unnamed NOT NULL constraint.

I would like to implement this without querying the data dictionary, but ... I am ready to do this if this is the only way. But I would like to use pure ALTER TABLE DDL.

+3
source share
2 answers

, - . , , . , ?

drop table testxx

 drop table testxx succeeded.
create table testxx ( id number not null ) 

create table succeeded.
select status from user_constraints where table_name = 'TESTXX'

STATUS   
-------- 
ENABLED  

1 rows selected

begin
 for cnames in ( select table_name,constraint_name from user_constraints where table_name = 'TESTXX' ) loop
    execute immediate 'alter table ' || cnames.table_name || ' disable constraint ' || cnames.constraint_name;
  end loop;
end;

anonymous block completed
select status from user_constraints where table_name = 'TESTXX'

STATUS   
-------- 
DISABLED 

1 rows selected
+4

create table test_null (col_n number not null);
alter table test_null modify col_n number null;
+5

Source: https://habr.com/ru/post/1780570/


All Articles