CREATE TABLE TIPOOPERACCLIE
(
    CDFILIAL           VARCHAR2(4), 
    IDENTRSAIDOP       VARCHAR2(1),
    CDTIPOOPER         VARCHAR2(2),
    NRSEQTPOPER        NUMBER,
    CDCLIENTE          VARCHAR2(21),
    CDFORNECED         VARCHAR2(21),
    DTINCLUSAO         DATE                   NULL    ,
    DTULTATU           DATE                   NULL    ,
    IDATIVO            VARCHAR2(1)            DEFAULT 'S' NOT NULL
        CONSTRAINT CKC_IDATIVO_TIPOOPERACCLIE CHECK (IDATIVO IN ('S','N')),
    NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT 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_TIPOOPERACCLIE PRIMARY KEY (CDFILIAL,  IDENTRSAIDOP, CDTIPOOPER,  NRSEQTPOPER)
)
/

ALTER TABLE PARAMGERAL ADD IDUTBLOQTPOPCLI VARCHAR2(01) DEFAULT 'N'
/

ALTER TABLE INTG_NOTAFISCAL DROP CONSTRAINT CKC_IDTIPOEMISNFE_INTGNF
/

ALTER TABLE INTG_NOTAFISCAL ADD CONSTRAINT CKC_IDTIPOEMISNFE_INTGNF CHECK (IDTIPOEMISNFE IN ('0','1','2','3','4','5','6','7','8','9'))
/

ALTER TABLE NOTAFISCAL DROP CONSTRAINT CKC_IDTIPOEMISNFE
/

ALTER TABLE NOTAFISCAL ADD CONSTRAINT CKC_IDTIPOEMISNFE CHECK (IDTIPOEMISNFE IN ('0','1','2','3','4','5','6','7','8','9'))
/