ALTER TABLE CONFCARD ADD IDRESERVAMYMENU VARCHAR2(1) DEFAULT 'S' NOT NULL
/
ALTER TABLE CONFCARD ADD CONSTRAINT CKC_CONFCARD_IDRESERVAMYMENU CHECK(IDRESERVAMYMENU IN ('S','N'))
/
ALTER TABLE CONTAINER ADD VRPESOCONTAINER FLOAT(126) NULL
/
CREATE TABLE TIPOSOBRA
(
    NRTIPOSOBRA                NUMBER                 NOT NULL,
    DSTIPOSOBRA                VARCHAR2(200)          NOT NULL,
    IDTIPOSOBRA                VARCHAR2(1)            DEFAULT 'I' NOT NULL
       CONSTRAINT CKC_IDTIPO_TIPOSOBRA CHECK (IDTIPOSOBRA IN ('I','P','S')),
    VRMETATIPOSOBRA            FLOAT(126)             NULL,    
    NRORG 					       NUMBER 			         DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL, 
	 IDATIVO 				       VARCHAR2(1) 	         DEFAULT 'S' NOT NULL 
       CONSTRAINT CKC_IDATIVO_TIPOSOBRA CHECK (IDATIVO IN ('S','N')),
	 DTINCLUSAO 				    DATE 					 	 NULL, 
	 DTULTATU 				       DATE 					 	 NULL,  
	 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' NULL,
		CONSTRAINT PK_TIPOSOBRA PRIMARY KEY (NRTIPOSOBRA)
)
/
CREATE INDEX TIPOSOBRA_PK ON TIPOSOBRA (NRORG ASC, NRTIPOSOBRA ASC)
/

CREATE TABLE METATIPOSOBRA
(
    NRMETATIPOSOBRA            NUMBER                 NOT NULL,
    NRTIPOSOBRA                NUMBER                 NOT NULL, 
    CDFILIAL                   VARCHAR2(4)            NOT NULL,
    CDSERVFILI                 VARCHAR2(5)            NULL,
    VRMETATIPOSOBRA            FLOAT(126)             NULL,    
    NRORG 					       NUMBER 			         DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL, 
	 IDATIVO 				       VARCHAR2(1) 	         DEFAULT 'S' NOT NULL 
       CONSTRAINT CKC_IDATIVO_METATIPOSOBRA CHECK (IDATIVO IN ('S','N')),
	 DTINCLUSAO 				    DATE 					 	 NULL, 
	 DTULTATU 				       DATE 					 	 NULL,  
	 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' NULL,
		CONSTRAINT PK_METATIPOSOBRA PRIMARY KEY (NRMETATIPOSOBRA)
)
/

CREATE INDEX METATIPOSOBRA_PK ON METATIPOSOBRA (NRORG ASC, NRMETATIPOSOBRA ASC)
/
ALTER TABLE METATIPOSOBRA ADD CONSTRAINT FKPLA01242METATPSOBRA_FILI FOREIGN KEY (CDFILIAL) REFERENCES FILIAL(CDFILIAL)
/
CREATE INDEX PLA01242_FK ON METATIPOSOBRA(CDFILIAL)
/
ALTER TABLE METATIPOSOBRA ADD CONSTRAINT FKPLA01243METATPSOBRA_SERV FOREIGN KEY (CDFILIAL, CDSERVFILI) REFERENCES SERVICO(CDFILIAL, CDSERVFILI)
/
CREATE INDEX PLA01243_FK ON METATIPOSOBRA(CDFILIAL, CDSERVFILI)
/
ALTER TABLE METATIPOSOBRA ADD CONSTRAINT FKPLA01244METATPSOBRA_TPSOB FOREIGN KEY (NRTIPOSOBRA) REFERENCES TIPOSOBRA(NRTIPOSOBRA)
/
CREATE INDEX PLA01244_FK ON METATIPOSOBRA(NRTIPOSOBRA)
/
CREATE TABLE MOTIVOSOBRA
(
    NRMOTIVOSOBRA              NUMBER                 NOT NULL,
    DSMOTIVOSOBRA              VARCHAR2(200)          NOT NULL,
    IDGERACUSTO                VARCHAR2(1)            DEFAULT 'N' NOT NULL, 
       CONSTRAINT CKC_IDGERACUSTO_MOTIVOSOBRA CHECK (IDGERACUSTO IN ('S','N')),
    NRORG 					       NUMBER 			         DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL, 
	 IDATIVO 				       VARCHAR2(1) 	         DEFAULT 'S' NOT NULL 
       CONSTRAINT CKC_IDATIVO_MOTIVOSOBRA CHECK (IDATIVO IN ('S','N')),
	 DTINCLUSAO 				    DATE 					 	 NULL, 
	 DTULTATU 				       DATE 					 	 NULL,  
	 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' NULL,
		CONSTRAINT PK_MOTIVOSOBRA PRIMARY KEY (NRMOTIVOSOBRA)
)
/

CREATE INDEX MOTIVOSOBRA_PK ON MOTIVOSOBRA(NRORG ASC, NRMOTIVOSOBRA ASC)
/
CREATE TABLE LANCTOSOBRA
(
    NRLANCTOSOBRA              NUMBER                 NOT NULL,
    CDFILIAL                   VARCHAR2(4)            NOT NULL,
    CDSERVFILI                 VARCHAR2(5)            NOT NULL,
    DTCARDAPIO                 DATE                    NOT NULL,
    CDFILCENTPME               VARCHAR2(4)            NULL,
    CDTIPOCARD                 VARCHAR2(10)           NULL,
    CDDIETPAD                  VARCHAR2(4)            NULL,
    NRTIPOSOBRA                NUMBER                 NOT NULL,
    NRMOTIVOSOBRA              NUMBER                 NULL,
    DSMOTIVOSOBRA              VARCHAR2(200)          NULL,
    CDPRATO                    VARCHAR2(10)           NULL,
    CDFILAUXPRAT               VARCHAR2(4)            NULL,
    CDCONTAINER                VARCHAR2(5)            NULL,
    VRPESOSOBRALIQ             FLOAT(126)             NOT NULL,
    VRPESOSOBRABRUTA           FLOAT(126)             NOT NULL,
    VRPESOCONTAINER            FLOAT(126)             NOT NULL,
    NRORG 					       NUMBER 			         DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL, 
	 IDATIVO 				       VARCHAR2(1) 	         DEFAULT 'S' NOT NULL 
       CONSTRAINT CKC_IDATIVO_LANCTOSOBRA CHECK (IDATIVO IN ('S','N')),
	 DTINCLUSAO 				    DATE 					 	 NULL, 
	 DTULTATU 				       DATE 					 	 NULL,  
	 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' NULL,
		CONSTRAINT PK_LANCTOSOBRA PRIMARY KEY (NRLANCTOSOBRA)
)
/
ALTER TABLE LANCTOSOBRA ADD CONSTRAINT FKPLA01245LANCTOSOBRA_SERV FOREIGN KEY (CDFILIAL, CDSERVFILI) REFERENCES SERVICO(CDFILIAL, CDSERVFILI)
/
CREATE INDEX FKPLA01245_FK ON LANCTOSOBRA(CDFILIAL, CDSERVFILI)
/
ALTER TABLE LANCTOSOBRA ADD CONSTRAINT FKPLA01246LANCTOSOBRA_TPCARD FOREIGN KEY (CDFILCENTPME, CDTIPOCARD) REFERENCES TIPOCARD(CDFILCENTPME, CDTIPOCARD)
/
CREATE INDEX FKPLA01246_FK ON LANCTOSOBRA(CDFILCENTPME, CDTIPOCARD)
/
ALTER TABLE LANCTOSOBRA ADD CONSTRAINT FKPLA01247LANCTOSOBRA_DIET FOREIGN KEY (CDDIETPAD) REFERENCES DIETPADR(CDDIETPAD)
/
CREATE INDEX FKPLA01247_FK ON LANCTOSOBRA(CDDIETPAD)
/
ALTER TABLE LANCTOSOBRA ADD CONSTRAINT FKPLA01248LANCTOSOBRA_CONT FOREIGN KEY (CDCONTAINER) REFERENCES CONTAINER(CDCONTAINER)
/
CREATE INDEX FKPLA01248_FK ON LANCTOSOBRA(CDCONTAINER)
/
ALTER TABLE LANCTOSOBRA ADD CONSTRAINT FKPLA01249LANCTOSOBRA_TPSOB FOREIGN KEY (NRTIPOSOBRA) REFERENCES TIPOSOBRA(NRTIPOSOBRA)
/
CREATE INDEX FKPLA01249_FK ON LANCTOSOBRA(NRTIPOSOBRA)
/
ALTER TABLE LANCTOSOBRA ADD CONSTRAINT FKPLA01250LANCTOSOBRA_MOTSOB FOREIGN KEY (NRMOTIVOSOBRA) REFERENCES MOTIVOSOBRA(NRMOTIVOSOBRA)
/
CREATE INDEX FKPLA01250_FK ON LANCTOSOBRA(NRMOTIVOSOBRA)
/
ALTER TABLE LANCTOSOBRA ADD CONSTRAINT FKPLA01251LANCTOSOBRA_PRATO FOREIGN KEY (CDPRATO, CDFILAUXPRAT) REFERENCES PRATO(CDPRATO, CDFILAUXPRAT)
/
CREATE INDEX FKPLA01251_FK ON LANCTOSOBRA(CDPRATO, CDFILAUXPRAT)
/
CREATE TABLE DEJETOSOBRA
(
    NRDEJETOSOBRA              NUMBER                 NOT NULL,
    DSDEJETOSOBRA              VARCHAR2(200)          NOT NULL,
    VRPERCDEJETOSOBRA          FLOAT(126)             NOT NULL, 
    NRORG 					       NUMBER 			         DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL, 
	 IDATIVO 				       VARCHAR2(1) 	         DEFAULT 'S' NOT NULL 
       CONSTRAINT CKC_IDATIVO_DEJETOSOBRA CHECK (IDATIVO IN ('S','N')),
	 DTINCLUSAO 				    DATE 					 	 NULL, 
	 DTULTATU 				       DATE 					 	 NULL,  
	 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' NULL,
		CONSTRAINT PK_DEJETOSOBRA PRIMARY KEY (NRDEJETOSOBRA)
)
/
CREATE TABLE ITDEJETOSOBRA 
(
    NRITDEJETOSOBRA            NUMBER                 NOT NULL,
    NRDEJETOSOBRA              NUMBER                 NOT NULL,
    NRLANCTOSOBRA              NUMBER                 NOT NULL,
    VRPESODEJETOSOBRA          FLOAT(126)             NOT NULL,
    VRPERCDEJETOSOBRA          FLOAT(126)             NOT NULL, 
    NRORG 					       NUMBER 			         DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL, 
	 IDATIVO 				       VARCHAR2(1) 	         DEFAULT 'S' NOT NULL 
       CONSTRAINT CKC_IDATIVO_ITDEJETOSOBRA CHECK (IDATIVO IN ('S','N')),
	 DTINCLUSAO 				    DATE 					 	 NULL, 
	 DTULTATU 				       DATE 					 	 NULL,  
	 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' NULL,
		CONSTRAINT PK_NRITDEJETOSOBRA PRIMARY KEY (NRITDEJETOSOBRA)
)
/
ALTER TABLE ITDEJETOSOBRA ADD CONSTRAINT FKPLA01252ITDEJETOSOBRA_DEJ FOREIGN KEY (NRDEJETOSOBRA) REFERENCES DEJETOSOBRA(NRDEJETOSOBRA) ON DELETE CASCADE
/
CREATE INDEX FKPLA01252_FK ON ITDEJETOSOBRA(NRDEJETOSOBRA)
/
ALTER TABLE ITDEJETOSOBRA ADD CONSTRAINT FKPLA01253ITDEJETOSOB_LANC FOREIGN KEY (NRLANCTOSOBRA) REFERENCES LANCTOSOBRA(NRLANCTOSOBRA) ON DELETE CASCADE
/
CREATE INDEX FKPLA01253_FK ON ITDEJETOSOBRA(NRLANCTOSOBRA)
/
ALTER TABLE CENARIOCARD MODIFY VRCUSTPADR VARCHAR2(100) NOT NULL
/
ALTER TABLE CENARIOCARD MODIFY VRPUCENARIO VARCHAR2(100) NOT NULL
/