CREATE TABLE TRANSCLIEPED
(
    CDCLIENTE         VARCHAR2(21)    NOT NULL,
    IDTPIJURTRAN      VARCHAR2(1) 	  NOT NULL,
    NRINSJURTRAN      VARCHAR2(20)    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_TRANSCLIEPED CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_TRANSCLIEPED PRIMARY KEY (CDCLIENTE, NRINSJURTRAN)
)
/

ALTER TABLE TRANSCLIEPED
   ADD CONSTRAINT FKPED00454TRANSCLIEPED_CLI FOREIGN KEY (CDCLIENTE)
      REFERENCES CLIENTE (CDCLIENTE)
/
CREATE INDEX PED00454_FK ON TRANSCLIEPED (CDCLIENTE)
/

ALTER TABLE TRANSCLIEPED
   ADD CONSTRAINT FKPED00455TRANSCLIPED_TRANSP FOREIGN KEY (IDTPIJURTRAN,NRINSJURTRAN)
      REFERENCES TRANSPORT (IDTPIJURTRAN, NRINSJURTRAN)
/

CREATE INDEX PED00455_FK ON TRANSCLIEPED (IDTPIJURTRAN,NRINSJURTRAN)
/

ALTER TABLE CLIENTE ADD IDPESQTRANSP  VARCHAR2(1) NULL
        CONSTRAINT CKC_IDPESQTRANSP  CHECK (IDPESQTRANSP  IS NULL OR IDPESQTRANSP   IN ('P','L'))
/ 