ALTER TABLE LOCAL ADD (
  SGLOCAL VARCHAR2(5) DEFAULT NULL NULL
)
/
CREATE TABLE TIPOCARDPESQ (
  CDTIPOCARDPESQ VARCHAR2(3) NOT NULL, 
  NMIPOCARDPESQ VARCHAR2(40) NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT NULL NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NULL,
  CONSTRAINT PK_TIPOCARDPESQ PRIMARY KEY(CDTIPOCARDPESQ, NRORG)
)
/
ALTER TABLE TIPOCARDPESQ ADD CONSTRAINT CKC_IDATIVO_TIPOCARDPESQ CHECK (IDATIVO IN ('S','N'))
/
CREATE TABLE COMPCARDPESQ (
  CDFILIAL VARCHAR2(4) NOT NULL, 
  NRCARDAPIO VARCHAR2(10) NOT NULL, 
  NRSEQPRATCAR VARCHAR2(3) NOT NULL, 
  CDFILAUXPRAT VARCHAR2(4) DEFAULT NULL NULL, 
  CDPRATO VARCHAR2(10) DEFAULT NULL NULL, 
  CDTIPOPRAT VARCHAR2(2) DEFAULT NULL NULL, 
  CDTIPOCARDPESQ VARCHAR2(3) DEFAULT NULL NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT NULL NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NULL,
  CONSTRAINT PK_COMPCARDPESQ PRIMARY KEY(CDFILIAL, NRCARDAPIO, NRSEQPRATCAR, NRORG)
)
/
ALTER TABLE COMPCARDPESQ ADD CONSTRAINT CKC_IDATIVO_COMPCARDPESQ CHECK (IDATIVO IN ('S','N'))