CREATE TABLE ETIQUETAECOMMERCE
(
   CDFORNECED 		VARCHAR2(21) 	NOT NULL, 
   CDOPERADOR 		VARCHAR2(12) 	NOT NULL,
   DSETIQUETA 		VARCHAR2(50) 	NOT NULL, 
   NRETIQUETA 		NUMBER 			NOT NULL,
   NRORG 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO 			VARCHAR2(1) 	DEFAULT 'S' NOT NULL,
		CONSTRAINT CKC_IDATIVO_ETIQECOMMERCE 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',
		CONSTRAINT PK_ETIQUETAECOMMERCE PRIMARY KEY (NRETIQUETA)
   )
/ 

ALTER TABLE AUTOFORNE ADD NRETIQUETA NUMBER NULL
/

CREATE INDEX PLA01231_FK ON AUTOFORNE (NRETIQUETA ASC)
/

ALTER TABLE AUTOFORNE
	ADD CONSTRAINT FKPLA01231ETIQUETAECOMMERCE FOREIGN KEY (NRETIQUETA)
		REFERENCES ETIQUETAECOMMERCE (NRETIQUETA) 
/

ALTER TABLE AUTOFORNE ADD TXJUSTIFICRECAF VARCHAR2(2000) NULL 
/

ALTER TABLE AUTOFORNE ADD IDSITUATENDIMENTOAF VARCHAR2(1) NULL
	CONSTRAINT CKC_IDSITUATENDOAF_AUTFOR CHECK (IDSITUATENDIMENTOAF IN ('C','R','P'))
/

ALTER TABLE ITEMAUTF ADD TXJUSTIFICRECITM VARCHAR2(2000) NULL
/

ALTER TABLE ITEMAUTF ADD IDSITUATENDIMENTOITM VARCHAR2(1) NULL 
	CONSTRAINT CKC_IDSITUATENDITM_ITEMAUTF CHECK (IDSITUATENDIMENTOITM IN ('C','R')) 