ALTER TABLE GRUPOPRATOPESQ ADD QTMAXRESERVA NUMBER
/

CREATE TABLE TIPOPRATGRUPOPESQ (
  NRGRUPOPRATOPESQ NUMBER           NOT NULL,
  CDTIPOPRAT       VARCHAR2(3)      NOT NULL,
  NRORG             NUMBER 	        DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
  DTINCLUSAO        DATE            DEFAULT SYSDATE,
  DTULTATU          DATE            DEFAULT SYSDATE,
  NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
  NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
	    CONSTRAINT CKC_IDATIVO_TPPRATGRUPOPESQ CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT PK_TIPOPRATGRUPOPESQ PRIMARY KEY(NRGRUPOPRATOPESQ, CDTIPOPRAT)
)
/

CREATE INDEX PLA01326_FK ON TIPOPRATGRUPOPESQ(NRGRUPOPRATOPESQ ASC)
/

ALTER TABLE TIPOPRATGRUPOPESQ ADD CONSTRAINT FKPLA01326GRPPESQ_TPPRATGPPESQ FOREIGN KEY (NRGRUPOPRATOPESQ) REFERENCES GRUPOPRATOPESQ (NRGRUPOPRATOPESQ) ON DELETE CASCADE
/

CREATE INDEX PLA01327_FK ON TIPOPRATGRUPOPESQ(CDTIPOPRAT ASC)
/

ALTER TABLE TIPOPRATGRUPOPESQ ADD CONSTRAINT FKPLA01327TPPRAT_TPPRATGPESQ FOREIGN KEY (CDTIPOPRAT) REFERENCES TIPOPRAT (CDTIPOPRAT) ON DELETE CASCADE
/
