CREATE TABLE PARAMABEECD (
	NRSEQUENCIAL  	  NUMBER NOT NULL,
	IDTPPARTECD   	  VARCHAR2(1)
		CONSTRAINT    CKC_PARAMABEECD_IDTPPARTECD CHECK (IDTPPARTECD IS NULL OR (IDTPPARTECD IN ('C','F', 'L'))),
	CDCLIENTE     	  VARCHAR2(21),
	CDFORNECED    	  VARCHAR2(21),
	CDFILIAL      	  VARCHAR2(4),
	IDCODRELAC    	  VARCHAR2(2)
		CONSTRAINT    CKC_PARAMABEECD_IDCODRELAC CHECK (IDCODRELAC IS NULL OR (IDCODRELAC IN ('01','02','03','04','05','06','07','08','09','10','11'))),
	DTINICIAL     	  DATE,
	DTFINAL       	  DATE,
    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_PARAMABEECD CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_PARAMABEECD PRIMARY KEY(NRSEQUENCIAL)
)
/

CREATE INDEX CTB00317_FK ON PARAMABEECD (CDCLIENTE ASC)
/

ALTER TABLE PARAMABEECD ADD CONSTRAINT FKCTB00317CLIENTE  FOREIGN KEY (CDCLIENTE) REFERENCES CLIENTE (CDCLIENTE)
/

CREATE INDEX CTB00318_FK ON PARAMABEECD (CDFORNECED ASC)
/

ALTER TABLE PARAMABEECD ADD CONSTRAINT FKCTB00318FORNECED FOREIGN KEY (CDFORNECED) REFERENCES FORNECEDOR (CDFORNECED)
/

CREATE INDEX CTB00319_FK ON PARAMABEECD (CDFILIAL ASC)
/

ALTER TABLE PARAMABEECD ADD CONSTRAINT FKCTB00319FILIAL  FOREIGN KEY (CDFILIAL) REFERENCES FILIAL (CDFILIAL)
/