CREATE TABLE ITEMPEDIDOSERV (
  NRITEMPEDIDOSERV NUMBER(10) NOT NULL, 
  NRPEDIDOSERV NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDSERVFILI VARCHAR2(5) NOT NULL, 
  QTDEPEDIDO NUMBER(10) NOT NULL, 
  DSOBSERVACAO VARCHAR2(200) 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_ITEMPEDIDOSERV PRIMARY KEY(NRITEMPEDIDOSERV, NRORG)
)
/
ALTER TABLE ITEMPEDIDOSERV ADD CONSTRAINT FKMYO00641PEDIDOSERV FOREIGN KEY (NRPEDIDOSERV, NRORG) REFERENCES PEDIDOSERV (NRPEDIDOSERV, NRORG)
/
ALTER TABLE ITEMPEDIDOSERV ADD CONSTRAINT FKMYO00642FILIAL FOREIGN KEY (CDFILIAL, NRORG) REFERENCES FILIAL (CDFILIAL, NRORG)
/
ALTER TABLE ITEMPEDIDOSERV ADD CONSTRAINT FKMYO00643SERVICO FOREIGN KEY (CDFILIAL, CDSERVFILI, NRORG) REFERENCES SERVICO (CDFILIAL, CDSERVFILI, NRORG)
/
ALTER TABLE ITEMPEDIDOSERV ADD CONSTRAINT CKC_IDATIVO_ITEMPEDIDOSERV CHECK (IDATIVO IN ('S', 'N'))
/
CREATE INDEX MYO00641_FK ON ITEMPEDIDOSERV (NRPEDIDOSERV, NRORG)
/
CREATE INDEX MYO00642_FK ON ITEMPEDIDOSERV (CDFILIAL, NRORG)
/
CREATE INDEX MYO00643_FK ON ITEMPEDIDOSERV (CDFILIAL, CDSERVFILI, NRORG)
/
ALTER TABLE SERVICO ADD (
  IDDISPOPEDIDOSERV VARCHAR2(1) DEFAULT 'N' NOT NULL, 
  NRLIMSEGPEDIDO NUMBER(10) DEFAULT NULL NULL, 
  DSOBSERVACAOSERVICO VARCHAR2(100) DEFAULT NULL NULL, 
  FGFOTOSERVICO CLOB DEFAULT NULL NULL
)
/
ALTER TABLE SERVICO ADD CONSTRAINT CKC_IDDISPOPEDIDOSERV_SERVICO CHECK (IDDISPOPEDIDOSERV IN ('S','N'))