ALTER TABLE TIPOBAIXAPAG DROP CONSTRAINT CKC_IDBAIXAUTILP
/

ALTER TABLE TIPOBAIXAPAG ADD CONSTRAINT CKC_IDBAIXAUTILP CHECK (
   IDBAIXAUTILP IS NULL OR (IDBAIXAUTILP IN ('A','M','C','L','D','T','S','B','O','E','F','G','P','R', 'H', 'J', 'I', 'K', 'N', 'Q', 'U', 'V', 'X','Z')))
/

CREATE TABLE CHAVEPIX (
   CDFORNECED      VARCHAR2(20)                       NOT NULL,
   IDCHAVEPIX      VARCHAR2(02)  DEFAULT 'C'          NOT NULL
      CONSTRAINT CKC_IDCHAVEPIX_CHAVEPIX CHECK(IDCHAVEPIX IN ('01','02','03','04')),
   CDCHAVEPIX      VARCHAR2(100)                      NOT NULL,
   DSCHAVEPIX      VARCHAR2(100)                      NULL,
   IDCHAVEPIXPREF  VARCHAR2(01)  DEFAULT 'N'          NOT NULL 
      CONSTRAINT CKC_IDCHAVEPIXPREF_CHAVEPIX CHECK(IDCHAVEPIXPREF IN('S','N')),
   NRORG           NUMBER        DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
   IDATIVO         VARCHAR2(1)	 DEFAULT 'S' 	        NOT NULL
      CONSTRAINT CKC_IDATIVO_CHAVEPIX   CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO      DATE          DEFAULT SYSDATE 			NULL,
   DTULTATU        DATE          DEFAULT SYSDATE 			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' 				  NULL,
   CONSTRAINT PK_CHAVEPIX PRIMARY KEY (CDFORNECED, IDCHAVEPIX, CDCHAVEPIX))
/

ALTER TABLE BOLETPAGAR ADD IDCHAVEPIX VARCHAR2(02)  NULL
/

ALTER TABLE BOLETPAGAR ADD CHAVEPIX VARCHAR2(100)   NULL
/ 

ALTER TABLE BOLETPAGAR ADD DSCHAVEPIX VARCHAR2(100) NULL
/

ALTER TABLE BOLETPAGAR ADD CODEQRPIX  VARCHAR2(100) NULL
/