CREATE TABLE DISPOSITIVOMYQ (
	NRDISPOSITIVOMYQ  NUMBER NOT NULL,
	NMDISPOSITIVOMYQ  VARCHAR2(100) NOT NULL,
	DSDISPOSITIVOMYQ  VARCHAR2(200) NULL,
	NRLOCALPESQ 	  NUMBER NOT NULL,
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
		CONSTRAINT CKC_IDATIVO_DISPOSITIVOMYQ CHECK (IDATIVO IN ('S', 'N')),	
		CONSTRAINT PK_DISPOSITIVOMYQ PRIMARY KEY(NRDISPOSITIVOMYQ)
)
/
ALTER TABLE DISPOSITIVOMYQ ADD CONSTRAINT FKPLA01323DISPOSITMYQ_LOCPESQ 
	FOREIGN KEY (NRLOCALPESQ)REFERENCES LOCALPESQ (NRLOCALPESQ) ON DELETE CASCADE
/
CREATE INDEX PLA01323_FK ON DISPOSITIVOMYQ (NRLOCALPESQASC)
/

CREATE TABLE MONITORDISPMYQ (
	NRDISPOSITIVOMYQ  NUMBER 	  	  NOT NULL,
	DSFUNCAO 		  VARCHAR2(100)   NOT NULL,
	DSRESOLUCAO 	  VARCHAR2(50) 	  NULL,
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
		CONSTRAINT CKC_IDATIVO_MONITORDISPMYQ CHECK (IDATIVO IN ('S', 'N')),
		CONSTRAINT PK_MONITORDISPMYQ PRIMARY KEY(NRDISPOSITIVOMYQ, DSFUNCAO))
/
ALTER TABLE MONITORDISPMYQ ADD CONSTRAINT FKPLA01324MONITOR_DISPMYQ
	FOREIGN KEY (NRDISPOSITIVOMYQ)REFERENCES DISPOSITIVOMYQ (NRDISPOSITIVOMYQ) ON DELETE CASCADE
/
CREATE INDEX PLA01324_FK ON MONITORDISPMYQ (NRDISPOSITIVOMYQ)
/