CREATE TABLE PERCITEMDETALGOP (
  NRPERCITEMGOP NUMBER(10) NOT NULL, 
  NRPERCITEMDETALGOP NUMBER(10) NOT NULL, 
  CDPRODUTO VARCHAR2(10) DEFAULT NULL NULL, 
  CDIMPOSTO VARCHAR2(2) DEFAULT NULL NULL, 
  CDTIPOOPER VARCHAR2(2) DEFAULT NULL NULL, 
  IDENTRSAIDOP VARCHAR2(1) DEFAULT NULL NULL, 
  CDINVEST VARCHAR2(10) DEFAULT NULL NULL, 
  CDORCAMENTOMO VARCHAR2(10) DEFAULT NULL NULL, 
  CDDESPPREV VARCHAR2(3) DEFAULT NULL NULL, 
  CDFILIALMO VARCHAR2(4) DEFAULT NULL NULL, 
  IDDESPPREV VARCHAR2(30) DEFAULT NULL NULL, 
  VRPERCENTUAL DOUBLE PRECISION DEFAULT NULL 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_PERCITEMDETALGOP PRIMARY KEY(NRPERCITEMDETALGOP)
)
/
ALTER TABLE PERCITEMDETALGOP ADD CONSTRAINT CKC_IDENTRSAIDOP_PERCITEMDETAL CHECK (IDENTRSAIDOP IS NULL OR (IDENTRSAIDOP IN ('E', 'S')))
/
ALTER TABLE PERCITEMDETALGOP ADD CONSTRAINT CKC_IDDESPPREV_PERCITEMDETAL CHECK (IDDESPPREV IS NULL OR (IDDESPPREV IN ('DIVERSA', 'MATRIZ', 'LANCENTRADA')))
/
ALTER TABLE PERCITEMDETALGOP ADD CONSTRAINT CKC_IDATIVO_PERCITEMDETALGOP CHECK (IDATIVO IN ('S', 'N'))
/
CREATE INDEX FKGOP00656PERCITEMGOP ON PERCITEMDETALGOP (NRPERCITEMGOP)