CREATE TABLE ALCADAGEROPER (
  NRALCADAGEROPER NUMBER(10) NOT NULL, 
  NRCONFIGALCADA NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDOPERADOR VARCHAR2(12) NOT NULL, 
  CDOPERRELACAP VARCHAR2(12) NOT NULL, 
  NRORG NUMBER(10) DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 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_ALCADAGEROPER PRIMARY KEY(NRALCADAGEROPER)
)
/
ALTER TABLE ALCADAGEROPER ADD CONSTRAINT CKC_IDATIVO_ALCADAGEROPER CHECK (IDATIVO IN ('S','N'))
/
ALTER TABLE ALCADAGEROPER ADD CONSTRAINT UN_ALCADAGEROPER UNIQUE (NRCONFIGALCADA, CDFILIAL, CDOPERADOR, CDOPERRELACAP)
/
ALTER TABLE ALCADAGEROPER ADD CONSTRAINT FKCMP00574CONFIGALCADA FOREIGN KEY (NRCONFIGALCADA) REFERENCES CONFIGALCADA (NRCONFIGALCADA)
/
CREATE INDEX FKCMP00574CONFIGALCADA ON ALCADAGEROPER (NRCONFIGALCADA)
/
ALTER TABLE ALCADAGEROPER ADD CONSTRAINT FKCMP00575FILIAL FOREIGN KEY (CDFILIAL) REFERENCES FILIAL (CDFILIAL)
/
CREATE INDEX FKCMP00575FILIAL ON ALCADAGEROPER (CDFILIAL)