Skip to Main Content

SQL Developer Data Modeler

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Inline PK, UC and CHECK constraints in generated DDL

user-4twyfMay 28 2023

Hi *,

I succesfully imported external DDL in Oracle SQL Developer, where syntax is based on inline constraints (if possible) in CREATE TABLE statement, like this below:

CREATE TABLE MY_TABLE
(
name varchar2 ( 14 ) NOT NULL CONSTRAINT UC_MyTable_name UNIQUE,
id number ( 38 ) NOT NULL CONSTRAINT PK_MyTable PRIMARY KEY,
FOREIGN_KEY_ID number ( 38 ) NOT NULL,
COLUMN_3 char ( 1 ) NULL,
CONSTRAINT RE_COLUMN_3 CHECK ( REGEXP_LIKE ( COLUMN_3, '[A-F0]' ) )
);
.......
ALTER TABLE MY_TABLE ADD CONSTRAINT FK_MyTable_AnotherTable FOREIGN KEY ( FOREIGN_KEY_ID ) REFERENCES AN_OTHER_TABLE ( id ) DEFERRABLE;

After exporting schema to ddl, I noticed that syntax is based on putting all constraints to ALTER TABLE statement

CREATE TABLE MY_TABLE
(
name VARCHAR2 ( 14 ) NOT NULL,
id NUMBER ( 38 ) NOT NULL,
FOREIGN_KEY_ID NUMBER ( 38 ) NOT NULL,
COLUMN_3 CHAR ( 1 ),
);
ALTER TABLE MY_TABLE ADD CONSTRAINT RE_COLUMN_3 CHECK ( REGEXP_LIKE ( COLUMN_3, '[A-F0]' ) );
ALTER TABLE MY_TABLE ADD CONSTRAINT PK_MyTable PRIMARY KEY ( id );
ALTER TABLE MY_TABLE ADD CONSTRAINT UC_MyTable_name UNIQUE ( name );
.....
ALTER TABLE MY_TABLE ADD CONSTRAINT FK_MyTable_AnotherTable FOREIGN KEY ( FOREIGN_KEY_ID ) REFERENCES AN_OTHER_TABLE ( id ) DEFERRABLE;

Is there any possibility to export schema to ddl, where all constraints except foreign key are placed in CREATE TABLE statement? Or maybe this must be forced during import? I know there are some limited options for that purpose

but they do not apply for this case.

I know that functionally it makes any difference, but I use some tools which supports only inline constraints.

Thanks for help in advance

Comments
Post Details
Added on May 28 2023
1 comment
834 views