John
John

Reputation: 105

Assign default value to TIMESTAMP_NTZ snowflake

I need to assign default value to column SERVERTIME with datatype TIMESTAMP_NTZ in snowflake. I have a below query:-

CREATE TABLE STG_ORDER_DETAIL
   (    
    ORDERID NUMBER(38,0) not null, 
    ORDER_TYPE VARCHAR(3), 
    AGGRID VARCHAR(20), 
    AGGRNAME VARCHAR(250), 
    MERCHANTID VARCHAR(20) not null, 
    SERVERTIME NOT NULL DEFAULT '1900-01-01'::TIMESTAMP_NTZ(9),
    CURRENCY VARCHAR(5),
    constraint STG_ORDER_DETAIL_PK primary key (ORDERID, MERCHANTID) not enforced);

getting syntax error.

Upvotes: 0

Views: 1250

Answers (1)

Gokhan Atil
Gokhan Atil

Reputation: 10059

Please make sure the data type is included and matched with the expression:

CREATE TABLE STG_ORDER_DETAIL
   (    
    ORDERID NUMBER(38,0) not null, 
    ORDER_TYPE VARCHAR(3), 
    AGGRID VARCHAR(20), 
    AGGRNAME VARCHAR(250), 
    MERCHANTID VARCHAR(20) not null, 
    SERVERTIME TIMESTAMP_NTZ(9) NOT NULL DEFAULT '1900-01-01'::TIMESTAMP_NTZ(9),
    CURRENCY VARCHAR(5),
    constraint STG_ORDER_DETAIL_PK primary key (ORDERID, MERCHANTID) not enforced);

Upvotes: 2

Related Questions