CREATE TABLE ADMINCARTFIL (
   CDTIPORECE     VARCHAR2(3)  NOT NULL,
   CDFILIAL       VARCHAR2(4)  NOT NULL,
   CDADMINCART    VARCHAR2(20) NOT NULL,
   NRORG          NUMBER       DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1)  DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ADMINCARTFIL CHECK (IDATIVO IN ('S','N')),
   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' NULL,
   CONSTRAINT PK_ADMINCARTFIL PRIMARY KEY (CDTIPORECE, CDFILIAL, CDADMINCART)
)
/

CREATE INDEX VND00881_FK ON ADMINCARTFIL (CDTIPORECE ASC)
/

ALTER TABLE ADMINCARTFIL
   ADD CONSTRAINT FKVND00881TIPORECE FOREIGN KEY (CDTIPORECE)
      REFERENCES TIPORECE (CDTIPORECE)
/

CREATE INDEX VND00882_FK ON ADMINCARTFIL (CDFILIAL ASC)
/

ALTER TABLE ADMINCARTFIL
   ADD CONSTRAINT FKVND00882FILIAL FOREIGN KEY (CDFILIAL)
      REFERENCES FILIAL (CDFILIAL)
/