CREATE TABLE CALCDIFALIMP
(
  CDIMPOSTO         VARCHAR2(02) NOT NULL,
  CDPAIS            VARCHAR2(04) NOT NULL,
  SGESTADO          VARCHAR2(02) NOT NULL,
  IDCALCDIFAL       VARCHAR2(01),
  IDCALCDIFALDENT   VARCHAR2(01),
  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_CALCDIFALIMP CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT PK_CALCDIFALIMP PRIMARY KEY (CDIMPOSTO, CDPAIS, SGESTADO)
)
/

CREATE INDEX FIS00897_FK ON CALCDIFALIMP (CDPAIS ASC, SGESTADO ASC)
/

ALTER TABLE CALCDIFALIMP
    ADD CONSTRAINT FKFIS00897CALCDIFALIMP FOREIGN KEY (CDPAIS, SGESTADO)
       REFERENCES ESTADO (CDPAIS, SGESTADO)
/

CREATE INDEX FIS00898_FK ON CALCDIFALIMP (CDIMPOSTO ASC)
/

ALTER TABLE CALCDIFALIMP
    ADD CONSTRAINT FKFIS00898CALCDIFALIMP FOREIGN KEY (CDIMPOSTO)
       REFERENCES IMPOSTO (CDIMPOSTO)
/

ALTER TABLE IMPOSTO ADD DSESTDIFALDENT VARCHAR2(500)
/