Etbin wrote:Thanks Etbin, that works, but that makes writing out a DDL script really complicated...have to query user_constraints to find the constraint name and then feed it as a variable. Doable, but really, is that the only way? I'm surprised NOT NULL is so radically different than other constraints.
alter table b_test rename constraint PK_B_TEST to B_TEST_PK;
Frank Kulash wrote:Ah! Thanks Frank. I guess I got lost in the train track diagrams and didn't see this option. This is perfect as I can now set it up at DDL-writing time.
You can easily name an in-line NOT NULL costraint:It is odd (and annoying) that you can't use an out-of-line constraint, like you tried.
ALTER TABLE t MODIFY first_name CONSTRAINT t_first_name_nn NOT NULL;
raindog wrote:I usually include all constraints (except foreign key constraints, sometimes) in the CREATE TABLE statement; in-line whenever possible.
... This is perfect as I can now set it up at DDL-writing time.
CREATE TABLE t ( id INTEGER CONSTRAINT t_pk PRIMARY KEY , first_name VARCHAR2 (30) CONSTRAINT t_first_name_nn NOT NULL , last_name VARCHAR2 (30) );