Temat: Migracja z Oracle na Postgresql
Witajcie,
Jestem totalnie zielony z postgres-a i prosiłby o pomoc w przepisaniu poniższego kodu tak aby działał na postgresql.
CREATE TABLE "BOOK"
( "ID_BOOK" NUMBER,
"TITLE" VARCHAR2(4000),
"AUTHOR" VARCHAR2(4000),
"YEAR" NUMBER,
"ISBORROW" NUMBER NOT NULL ENABLE,
CONSTRAINT "BOOK_PK" PRIMARY KEY ("ID_BOOK") ENABLE
)
/
CREATE SEQUENCE "BOOK_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE
/
CREATE OR REPLACE TRIGGER "BI_BOOK"
before insert on "BOOK"
for each row
begin
select "BOOK_SEQ".nextval into :NEW.ID_BOOK from dual;
end;
/
ALTER TRIGGER "BI_BOOK" ENABLE
/
CREATE TABLE "BORROWED"
( "ID_BORROWED" NUMBER,
"ID_LIB_USER" NUMBER,
"ID_BOOK" NUMBER,
"BORROW_DATE" VARCHAR2(4000),
"TO_DATE" VARCHAR2(4000),
CONSTRAINT "BORROWED_PK" PRIMARY KEY ("ID_BORROWED") ENABLE
)
/
CREATE SEQUENCE "BORROWED_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE
/
CREATE OR REPLACE TRIGGER "BI_BORROWED"
before insert on "BORROWED"
for each row
begin
select "BORROWED_SEQ".nextval into :NEW.ID_BORROWED from dual;
end;
/
ALTER TRIGGER "BI_BORROWED" ENABLE
/
CREATE TABLE "LIBE_USER"
( "ID_LIBE_USER" NUMBER,
"NAME" VARCHAR2(4000),
"SURNAME" VARCHAR2(4000),
"ADRESS" VARCHAR2(4000),
"TELEPHONE" NUMBER,
CONSTRAINT "LIBE_USER_PK" PRIMARY KEY ("ID_LIBE_USER") ENABLE
)
/
CREATE SEQUENCE "LIBE_USER_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE
/
CREATE OR REPLACE TRIGGER "BI_LIBE_USER"
before insert on "LIBE_USER"
for each row
begin
select "LIBE_USER_SEQ".nextval into :NEW.ID_LIBE_USER from dual;
end;
/
ALTER TRIGGER "BI_LIBE_USER" ENABLE
/
Z góry dziękuję:)