declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate 'CREATE TABLE CONVENIO_TRANSPORTADORA (
                        CONVENIOTRANSPORTADORA_ID NUMBER(7,0) PRIMARY KEY,
                        TRANSPORTADORA_ID NUMBER(7,0),
                        NOME_CONVENIO VARCHAR2(150),
                        NUMCONVENIO VARCHAR2(50),
                        VALOR NUMBER(15,2), 
                        TIPO_CONVENIO NUMBER(7,0), 
                        DATA_INICIAL DATE,
                        DATA_FINAL DATE,
                        USUARIO_ID NUMBER(7,0),
                        ACTIVO NUMBER(1,0),
                        FECMODIF DATE, 
                        CONSTRAINT fk_transportadora_convenio FOREIGN KEY (TRANSPORTADORA_ID) REFERENCES TRANSPORTADORA(TRANSPORTADORA_ID),
                        CONSTRAINT fk_usuario_convenio_transportadora FOREIGN KEY (USUARIO_ID) REFERENCES USUARIO(USUARIO_ID)
                    )';
  exception when object_exists then null;
end;
/

declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate 'CREATE SEQUENCE "CONVENIO_TRANSPORTADORA_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE';
  exception when object_exists then null;
end;
/
