CREATE TABLE DEVICE (
	NRDEVICE				NUMBER 														NOT NULL,
	UUID					VARCHAR2(50)												NOT NULL,
	TOKEN					VARCHAR2(2000)												NOT NULL,
	CDOPERADOR     			VARCHAR2(12)												NOT NULL,
	PLATFORM				VARCHAR2(20)												NOT NULL,
	NRAPLICATIVO			NUMBER														NOT NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_DEVICE CHECK (IDATIVO IN ('S', 'N')),
	DTINCLUSAO 				DATE 														NULL,
	DTULTATU 				DATE 														NULL,
	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' 								NULL,
	CONSTRAINT PK_DEVICE PRIMARY KEY (NRDEVICE), 
	CONSTRAINT UN_DEVICE UNIQUE (TOKEN),
	CONSTRAINT UN_DEVICE_02 UNIQUE (UUID)
)
/
ALTER TABLE DEVICE ADD
	CONSTRAINT FKGER00670OPERADOR FOREIGN KEY (CDOPERADOR)
		REFERENCES OPERADOR (CDOPERADOR)
/
CREATE INDEX FKGER00670OPERADOR ON DEVICE (CDOPERADOR)
/
ALTER TABLE DEVICE ADD
	CONSTRAINT FKGER00671APPAPLICATIVO FOREIGN KEY (NRAPLICATIVO)
		REFERENCES APP_APLICATIVO (NRAPLICATIVO)
/
CREATE INDEX FKGER00671APPAPLICATIVO ON DEVICE (NRAPLICATIVO)
/
CREATE SEQUENCE DEVICE_SEQ START WITH 1 INCREMENT BY 1