Home > Software engineering >  Create table in snowflake - Syntax
Create table in snowflake - Syntax

Time:03-01

I am trying to create a table and insert rows into it. But it keeps giving me this syntax error. ERROR : SQL compilation error: syntax error line 3 at position 1 unexpected 'EventName'. syntax

Any help would be appreciated.

create or replace table pd_press_dev._raz.ID (
     EventTypeID int
     EventName,
     EventDescription,
     EventCategoryName,
     SystemName,
     RecordChecksum,
     RecordAppend,
     RecordUpdate);
     
    INSERT INTO pd_press_dev._raz.ID 
    (-1,'NO_EVENT_TYPE','Event Type Not Defined','NO_EVENT_CATEGORY','INSITE','-770355665','0.00218634259259259','0.00218634259259259'); 

CodePudding user response:

You need to type those columns, and you are missing a comma after the int of EnventTypeID

create or replace table pd_press_dev._raz.ID (
     EventTypeID int,
     EventName text,
     EventDescription text,
     EventCategoryName text,
     SystemName text,
     RecordChecksum text,
     RecordAppend text,
     RecordUpdate text);

and your insert needs a VALUES keyword:

INSERT INTO pd_press_dev._raz.ID values
    (-1, 'NO_EVENT_TYPE', 'Event Type Not Defined', 'NO_EVENT_CATEGORY', 
       'INSITE', '-770355665', '0.00218634259259259', '0.00218634259259259');      
SELECT * FROM ID;
EVENTTYPEID EVENTNAME EVENTDESCRIPTION EVENTCATEGORYNAME SYSTEMNAME RECORDCHECKSUM RECORDAPPEND RECORDUPDATE
-1 NO_EVENT_TYPE Event Type Not Defined NO_EVENT_CATEGORY INSITE -770355665 0.00218634259259259 0.00218634259259259
  • Related