WITH xml AS ( SELECT DBMS_XMLGEN.GETXMLTYPE( 'select co.constraint_name , co.table_name , cc.column_name , co.constraint_type , co.r_constraint_name , co.search_condition from user_constraints co left outer join user_cons_columns cc on co.constraint_name = cc.constraint_name where co.generated = ''GENERATED NAME''') AS xml FROM dual ), concol as ( SELECT extractValue(xs.object_value, '/ROW/TABLE_NAME') AS table_name , extractValue(xs.object_value, '/ROW/COLUMN_NAME') AS column_name , extractValue(xs.object_value, '/ROW/CONSTRAINT_TYPE') AS constraint_type , extractValue(xs.object_value, '/ROW/CONSTRAINT_NAME') AS constraint_name , extractValue(xs.object_value, '/ROW/R_CONSTRAINT_NAME') AS r_constraint_name , extractValue(xs.object_value, '/ROW/SEARCH_CONDITION') AS search_condition FROM xml x , TABLE(XMLSEQUENCE(EXTRACT(x.xml, '/ROWSET/ROW'))) xs ) select cc.* from concol cc order by table_name, column_name,constraint_type ;
Give names to the reported constraints to your modeling tool. NOT NULL checks are not first in the list to be named. NOT NULL error messages are informative with the generated names also. But naming also those make the different (DEV,TST,PRD) schemas a bit more similar. SQL Developer Data modeler 3.1 EA3 has the possibility to name those also at relational model. Formerly it was only possible at physical model. If you feel like too much work modeling those at least change the reported names.
ALTER TABLE test RENAME CONSTRAINT SYS_C006206630 TO test_pk;
No comments:
Post a Comment