Skip to main content

Based on understanding of Vertica SQL/Postgre SQL, following piece of script I am implementing to enable primary key. But even after successful, error free execution of these statements, I can see Celonis allows INSERT with same values. Can you help me in understanding if I am falling short on something to enable primary key?

 

CREATE TABLE _CEL_ACTIVITY_PRIMARY_TEST(

    _case   varchar(25),

    activity_name varchar(100) not null,

    eventime DATETIME not null,

    PRIMARY KEY(_case)

);

 

SELECT * FROM _CEL_ACTIVITY_PRIMARY_TEST;

 

INSERT INTO _CEL_ACTIVITY_PRIMARY_TEST VALUES ('1234','act1','2022-08-22T09:46:46');

Hello Siddhesh,

 

Whether constraints of primary key work or not is dependent on configuration parameter. Please refer to the below link for the details.

Enforcing Primary Key, Unique Key, and Check Constraints Automatically (vertica.com)

 

So that the constraints will be always enabled, you could explicitly state that like below.

 

CREATE TABLE _CEL_ACTIVITY_PRIMARY_TEST(

    _case   varchar(25),

    activity_name varchar(100) not null,

    eventime DATETIME not null,

    CONSTRAINT pk PRIMARY KEY (_case) ENABLED

);

 

Regards,


Hello Siddhesh,

 

Whether constraints of primary key work or not is dependent on configuration parameter. Please refer to the below link for the details.

Enforcing Primary Key, Unique Key, and Check Constraints Automatically (vertica.com)

 

So that the constraints will be always enabled, you could explicitly state that like below.

 

CREATE TABLE _CEL_ACTIVITY_PRIMARY_TEST(

    _case   varchar(25),

    activity_name varchar(100) not null,

    eventime DATETIME not null,

    CONSTRAINT pk PRIMARY KEY (_case) ENABLED

);

 

Regards,

Thanks Takahashi.... that worked!


Reply