CREATE TABLE SERVICOLOCALPESQ (
  NRSERVICOLOCALPESQ    NUMBER NOT NULL,
  NRLOCALPESQ           NUMBER NOT NULL, 
  CDFILIAL              VARCHAR2(4) NOT NULL,
  CDSERVFILI            VARCHAR2(5) NOT NULL,
  IDATIVO               VARCHAR2(1) DEFAULT 'S' NOT NULL
     CONSTRAINT CKC_SERVICOLOCALPESQ CHECK (IDATIVO IN('S','N')), 
  NRORG                 NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL, 
  DTINCLUSAO            DATE DEFAULT SYSDATE,
  CDOPERINCLUSAO        VARCHAR2(12) DEFAULT '1', 
  CDOPERULTATU          VARCHAR2(12) DEFAULT '1', 
  NRORGINCLUSAO         NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'), 
  NRORGULTATU           NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'), 
  DTULTATU              DATE DEFAULT SYSDATE,
  CONSTRAINT PK_SERVICOLOCALPESQ PRIMARY KEY(NRSERVICOLOCALPESQ),
  CONSTRAINT FKPLA01304SERVLOCPESQ_LOC  FOREIGN KEY (NRLOCALPESQ)
		REFERENCES LOCALPESQ (NRLOCALPESQ) ON DELETE CASCADE,
  CONSTRAINT FKPLA01305SERVLOCPESQ_SERV  FOREIGN KEY (CDFILIAL, CDSERVFILI) 
		REFERENCES SERVICO (CDFILIAL, CDSERVFILI) ON DELETE CASCADE
)
/
CREATE INDEX FKPLA01304_FK ON SERVICOLOCALPESQ (NRLOCALPESQ ASC)
/
CREATE INDEX FKPLA01305_FK ON SERVICOLOCALPESQ (CDFILIAL ASC, CDSERVFILI ASC)
/