23-May-07 (Created: 23-May-07) | More in 'CS-dotnet'

creating a table in oracle


CREATE table "SWN_QUERY" (
    "QUERY_ID"   NUMBER NOT NULL,
    "QUERY_NAME" VARCHAR2(4000),
    "QUERY_DESC" VARCHAR2(4000),
    "QUERY_BODY" VARCHAR2(4000),
    "USER_ID"    CHAR(100),
    constraint  "SWN_QUERY_PK" primary key ("QUERY_ID")
)
/

CREATE sequence "SWN_QUERY_SEQ" 
/

CREATE trigger "BI_SWN_QUERY"  
  before insert on "SWN_QUERY"              
  for each row 
begin  
    select "SWN_QUERY_SEQ".nextval into :NEW.QUERY_ID from dual;
end;
/   

alter table "SWN_QUERY" add
constraint SWN_QUERY_NAME_UK
unique ("QUERY_NAME")
/