Oracle
 SQL >> Datenbank >  >> RDS >> Oracle

Prüfen, ob eine Oracle-Spalte nullable ist, bevor man sie ändert

Du kannst das sauber in PL/SQL handhaben:

declare l_nullable user_tab_columns.nullable%type; begin select nullable into l_nullable from user_tab_columns where table_name = 'MYTABLE' and column_name = 'MYCOLUMN'; if l_nullable = 'N' then execute immediate 'alter table mytable modify (mycolumn null)'; end if; end;