CREATE TABLE OM_COLETA_MEDIDA_VARIAVEL( 
  ID                 	NUMBER 		NOT NULL,
  QTD_DIAS_REAPLICAR 	NUMBER 		NOT NULL,
  QTD_DIAS_AVISO     	NUMBER 		NOT NULL,
  CDTPMEDIDASERV     	NUMBER 		NOT NULL,
  CDSERVORCA         	NUMBER 		NOT NULL,
  PHP_SCRIPT_COUNT   	CLOB 		NOT NULL,
  PHP_SCRIPT_LOG     	CLOB 		NOT NULL,
  NRORG          		NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL , 
  NRORGINCLUSAO  		NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL , 
  NRORGULTATU    		NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL , 
  DTINCLUSAO     		DATE,
  DTULTATU       		DATE,
  CDOPERINCLUSAO 		VARCHAR2(12),
  CDOPERULTATU   		VARCHAR2(12),
  IDATIVO        		VARCHAR2(1) DEFAULT 'S' NOT NULL,
	CONSTRAINT PK_OM_COLETA_MEDIDA_VARIAVEL PRIMARY KEY(ID),
	CONSTRAINT CKC_IDATIVO_OM_COLETA_MED    CHECK (IDATIVO IN ('S', 'N')),
	CONSTRAINT OM_COLETA_MED_FCT_TIPOMED    FOREIGN KEY (CDTPMEDIDASERV) REFERENCES FCT_TIPOMEDIDASERV (CDTPMEDIDASERV),
	CONSTRAINT OM_COLETA_MED_FCT_SERV       FOREIGN KEY (CDSERVORCA)     REFERENCES FCT_SERVICOORCA (CDSERVORCA)
)
/

ALTER TABLE OPERADOR_ACESSO ADD TOKEN VARCHAR2(100)
/

ALTER TABLE OPERADOR_ACESSO ADD NRTEMPOVIDATOKEN NUMBER
/

ALTER TABLE OPERADOR_ACESSO ADD IDMANTERCONECTADO VARCHAR2(1) DEFAULT 'N' NOT NULL
/

ALTER TABLE OPERADOR_ACESSO ADD CONSTRAINT OPER_ACE_IDMANTCON CHECK (IDMANTERCONECTADO IN ('S', 'N'))