I'm new to using Oracle
, I used firebird
before. I would like to know, why I can not create multiple tables at once in the sql master of SQLdeveloper
. It creates only the first table (Country).
I try to execute the following statements, to create all the tables at once. (in this case I'm only using 3 tables to not get too long).
CREATE TABLE PAIS
(
IdPais INTEGER NOT NULL,
NomePais VARCHAR(60) NOT NULL,
SiglaPais VARCHAR(3) NOT NULL,
StatusPais CHAR(1) NOT NULL
);
ALTER TABLE PAIS ADD
(
CONSTRAINT PAIS PRIMARY KEY (IdPais)
);
CREATE SEQUENCE SEQ_ID_PAIS
MINVALUE 1
MAXVALUE 9999999999
START WITH 1
INCREMENT BY 1
NOCACHE
CYCLE;
CREATE OR REPLACE TRIGGER TRG_ID_PAIS BEFORE INSERT ON PAIS FOR EACH ROW BEGIN <<COLUMN_SEQUENCES>> BEGIN IF :NEW.IDPAIS IS NULL THEN SELECT SEQ_ID_PAIS.NEXTVAL INTO :NEW.IDPAIS FROM DUAL; END IF; END COLUMN_SEQUENCES; END;
CREATE TABLE ESTADO
(
IdEstado INTEGER NOT NULL,
IdPais INTEGER NOT NULL,
NomeEstado VARCHAR(60) NOT NULL,
SiglaEstado VARCHAR(2) NOT NULL,
StatusEstado CHAR(1) NOT NULL
);
ALTER TABLE ESTADO ADD
(
CONSTRAINT ESTADO PRIMARY KEY (IdEstado)
);
CREATE SEQUENCE SEQ_ID_ESTADO
MINVALUE 1
MAXVALUE 9999999999
START WITH 1
INCREMENT BY 1
NOCACHE
CYCLE;
CREATE OR REPLACE TRIGGER TRG_ID_ESTADO BEFORE INSERT ON ESTADO FOR EACH ROW BEGIN <<COLUMN_SEQUENCES>> BEGIN IF :NEW.IDESTADO IS NULL THEN SELECT SEQ_ID_ESTADO.NEXTVAL INTO :NEW.IDESTADO FROM DUAL; END IF; END COLUMN_SEQUENCES; END;
CREATE TABLE CIDADE
(
IdCidade INTEGER NOT NULL,
IdEstado INTEGER NOT NULL,
NomeCidade VARCHAR(60) NOT NULL,
StatusCidade CHAR(1) NOT NULL
);
ALTER TABLE CIDADE ADD
(
CONSTRAINT CIDADE PRIMARY KEY (IdCidade)
);
CREATE SEQUENCE SEQ_ID_CIDADE
MINVALUE 1
MAXVALUE 9999999999
START WITH 1
INCREMENT BY 1
NOCACHE
CYCLE;
CREATE OR REPLACE TRIGGER TRG_ID_CIDADE BEFORE INSERT ON CIDADE FOR EACH ROW BEGIN <<COLUMN_SEQUENCES>> BEGIN IF :NEW.IDCIDADE IS NULL THEN SELECT SEQ_ID_CIDADE.NEXTVAL INTO :NEW.IDCIDADE FROM DUAL; END IF; END COLUMN_SEQUENCES; END;