Toad World® Forums

Unique key constraints with nullable columns

I’m using TDM 5.4.6.12.

I need to create a unique key constraint with two columns, one of them is nullable. It’s not enough to create an unique Index, I need the constraint

Hi,

what is your target database platform, please? And if possible, can you publish the expected SQL code for the scenario?

Thanks,

Vaclav

Platform is Oracle 12.1.0.2

CREATE TABLE FUELS_HIST

(

ID NUMBER(18,0) constraint nn_fueh_id NOT NULL,

NAME VARCHAR2(200 CHAR) constraint nn_fueh_name NOT NULL,

VALIDFROM DATE constraint nn_fueh_validfrom NOT NULL,

VALIDTO DATE,

VALIDTO_COMMENT VARCHAR2(500 CHAR)

)

TABLESPACE PPHISTDATA;

Prompt Non-Foreign Key Constraints on Table FUELS_HIST;

ALTER TABLE FUELS_HIST ADD (

CONSTRAINT UK_FUEH

UNIQUE (ID, VALIDTO) using index tablespace pphistindexes);

When I create the constraint manually, validto is not null.

When I insert the entity by reverse engineering, the validto is nullable.

Hi Christa,

Go to Main Menu - Settings - Option - Physical Model. There is checkbox “Allow Null Attributes in Keys”. I think this is what you looking for.

Daril

Thank you, works fine

Christa