Created
March 22, 2025 09:36
-
-
Save abarhub/760978599f6e8043f5e6e7d5e1f0d847 to your computer and use it in GitHub Desktop.
Supprime la contrainte not null d'une colonne dont le nom de la contrainte n'est pas connue. Spécifique à Oracle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- suppression de la contrainte not null du champs mon_schema.ma_table.mon_champs | |
| declare | |
| fName varchar2(255 char); | |
| begin | |
| SELECT x.constraint_name into fName FROM all_constraints x | |
| JOIN all_cons_columns c ON | |
| c.table_name = x.table_name AND c.constraint_name = x.constraint_name | |
| WHERE x.table_name = 'ma_table' AND x.OWNER='mon_schema' AND x.constraint_type = 'C' AND c.column_name ='mon_champs'; | |
| if fName is not null THEN | |
| execute immediate 'ALTER TABLE "mon_schema"."ma_table" DROP CONSTRAINT ' || fName; | |
| end if; | |
| end; | |
| / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment