DROP TABLE OraJobsTest;
CREATE TABLE OraJobsTest(
TRGT_HOST       varchar(32) NOT NULL,
PORT_NO         varchar(32) NOT NULL,
SITE_NAME       varchar(64) NOT NULL,
INFO            varchar(128) NOT NULL,
MSMT_HOST       varchar(32) NOT NULL,
MSMT_TIME       datetime NOT NULL,
TOTAL_FAILED_JOBS DECIMAL(20,4) NOT NULL,
TOTAL_FAILED_JOBS_ST varchar(32) NOT NULL,
TOTAL_BROKEN_JOBS DECIMAL(20,4) NOT NULL,
TOTAL_BROKEN_JOBS_ST varchar(32) NOT NULL,
NUM_RUNNING_JOBS DECIMAL(20,4) NOT NULL,
NUM_RUNNING_JOBS_ST varchar(32) NOT NULL,
MAX_CPU_TIME DECIMAL(20,4) NOT NULL,
MAX_CPU_TIME_ST varchar(32) NOT NULL,
MAX_RUN_TIME DECIMAL(20,4) NOT NULL,
MAX_RUN_TIME_ST varchar(32) NOT NULL,
SUCCESSFULL_JOBS DECIMAL(20,4) NOT NULL,
SUCCESSFULL_JOBS_ST varchar(32) NOT NULL
);

CREATE INDEX IDX_OraJobsTest ON OraJobsTest(MSMT_TIME);
ALTER TABLE OraJobsTest ADD constraint PK_OraJobsTest PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST, MSMT_TIME);

DROP TABLE OraJobsTest_TREND;
CREATE TABLE OraJobsTest_TREND(
TRGT_HOST       varchar(32) NOT NULL,
PORT_NO         varchar(32) NOT NULL,
SITE_NAME       varchar(64) NOT NULL,
INFO            varchar(128) NOT NULL,
MSMT_HOST       varchar(32) NOT NULL,
MSMT_TIME       datetime NOT NULL,
PERIOD       	varchar(32) NOT NULL,
TOTAL_FAILED_JOBS_MIN DECIMAL(20,4) NOT NULL,
TOTAL_FAILED_JOBS_MAX DECIMAL(20,4) NOT NULL,
TOTAL_FAILED_JOBS_STCNT varchar(32) NOT NULL,
TOTAL_BROKEN_JOBS_MIN DECIMAL(20,4) NOT NULL,
TOTAL_BROKEN_JOBS_MAX DECIMAL(20,4) NOT NULL,
TOTAL_BROKEN_JOBS_STCNT varchar(32) NOT NULL,
NUM_RUNNING_JOBS_MIN DECIMAL(20,4) NOT NULL,
NUM_RUNNING_JOBS_MAX DECIMAL(20,4) NOT NULL,
NUM_RUNNING_JOBS_STCNT varchar(32) NOT NULL,
MAX_CPU_TIME_MIN DECIMAL(20,4) NOT NULL,
MAX_CPU_TIME_MAX DECIMAL(20,4) NOT NULL,
MAX_CPU_TIME_STCNT varchar(32) NOT NULL,
MAX_RUN_TIME_MIN DECIMAL(20,4) NOT NULL,
MAX_RUN_TIME_MAX DECIMAL(20,4) NOT NULL,
MAX_RUN_TIME_STCNT varchar(32) NOT NULL,
SUCCESSFULL_JOBS_MIN DECIMAL(20,4) NOT NULL,
SUCCESSFULL_JOBS_MAX DECIMAL(20,4) NOT NULL,
SUCCESSFULL_JOBS_STCNT varchar(32) NOT NULL
);

ALTER TABLE OraJobsTest_TREND ADD constraint PK_OraJobsTest_TREND PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST, MSMT_TIME,PERIOD);

DROP TABLE OraJobsTest_THRESH;
CREATE TABLE OraJobsTest_THRESH(
TRGT_HOST       varchar(32) NOT NULL,
PORT_NO         varchar(32) NOT NULL,
SITE_NAME       varchar(64) NOT NULL,
INFO            varchar(128) NOT NULL
,MSMT_HOST       varchar(32) NOT NULL,
MSMT_TIME_START datetime NOT NULL,
MSMT_TIME_END   datetime NOT NULL,
TOTAL_FAILED_JOBS_MIN VARCHAR(256) NOT NULL,
TOTAL_FAILED_JOBS_MAX VARCHAR(256) NOT NULL,
TOTAL_BROKEN_JOBS_MIN VARCHAR(256) NOT NULL,
TOTAL_BROKEN_JOBS_MAX VARCHAR(256) NOT NULL,
NUM_RUNNING_JOBS_MIN VARCHAR(256) NOT NULL,
NUM_RUNNING_JOBS_MAX VARCHAR(256) NOT NULL,
MAX_CPU_TIME_MIN VARCHAR(256) NOT NULL,
MAX_CPU_TIME_MAX VARCHAR(256) NOT NULL,
MAX_RUN_TIME_MIN VARCHAR(256) NOT NULL,
MAX_RUN_TIME_MAX VARCHAR(256) NOT NULL,
SUCCESSFULL_JOBS_MIN VARCHAR(256) NOT NULL,
SUCCESSFULL_JOBS_MAX VARCHAR(256) NOT NULL
);

ALTER TABLE OraJobsTest_THRESH ADD constraint PK_OraJobsTest_THRESH PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST,MSMT_TIME_START);
CREATE INDEX IDX_OraJobsTest_THRESH ON OraJobsTest_THRESH (MSMT_HOST,MSMT_TIME_START,MSMT_TIME_END);
CREATE INDEX IDX_TH_OraJobsTest ON OraJobsTest_THRESH (MSMT_TIME_START);
CREATE INDEX IDX_TR_OraJobsTest ON OraJobsTest_TREND (MSMT_TIME,PERIOD);

DROP TABLE CtxXcXALoginTest_REPORT;
CREATE TABLE CtxXcXALoginTest_REPORT ( 
SESSION_KEY VARCHAR(128),  
SESSION_NAME VARCHAR(32),  
SESSION_ID VARCHAR(32),  
TRGT_HOST VARCHAR(32),  
PORT_NO VARCHAR(32),  
USERNAME VARCHAR(128) NOT NULL,
MSMT_TIME DATETIME NOT NULL,
LOGIN_TIME DATETIME NOT NULL,
DURATION DECIMAL (20,4) NOT NULL,
ACTIVE_TIME DECIMAL (20,4) NOT NULL,
IDLE_TIME DECIMAL (20,4) NOT NULL,
CLIENT_IP_ADDRESS VARCHAR(128),
CLIENT_NAME VARCHAR(128),
CLIENT_VERSION VARCHAR(128),
CLIENT_TYPE VARCHAR(128),
CLIENT_ID VARCHAR(128),
CLIENT_CATEGORY VARCHAR(128),
CTX_STATE VARCHAR(128),
HDX_DISPLAY_MODE VARCHAR(128),
HDX_ACTIVE_ENCODER VARCHAR(128),
HDX_PROTOCOL VARCHAR(128),
ENCRYPTION_LEVEL VARCHAR(128),
NETSCALER_RPTNAME VARCHAR(128),
NETSCALER_IP_ADDRESS VARCHAR(128),
XENAPP_IP_ADDRESS VARCHAR(128),
ENDPOINT_IP_ADDRESS VARCHAR(128),
COUNTRY_NAME VARCHAR(128),
COUNTRY_CODE VARCHAR(128),
REGION VARCHAR(128),
CITY VARCHAR(128),
LATITUDE VARCHAR(128),
LONGITUDE VARCHAR(128),
LOGON_DURATION DECIMAL (20,4) NOT NULL,
ACTUAL_LOGON_DURATION DECIMAL (20,4) NOT NULL,
CPU_UTIL DECIMAL (20,4) NOT NULL,
MEM_UTIL DECIMAL (20,4) NOT NULL,
LATENCY_AVG DECIMAL (20,4) NOT NULL,
ICA_NWLATENCY DECIMAL (20,4) NOT NULL,
FRAME_RATE DECIMAL (20,4) NOT NULL,
FRAMEHAWK DECIMAL (20,4) NOT NULL,
IO_READS DECIMAL (20,4) NOT NULL,
IO_WRITES DECIMAL (20,4) NOT NULL,
ROUND_TRIP_TIME DECIMAL (20,4) NOT NULL,
CONNECTION_STRENGTH DECIMAL(20,4) NOT NULL,
OUTPUT_LINE_SPEED DECIMAL(20,4) NOT NULL
);
CREATE INDEX IDX_CtxXcXALoginTest_REPORT ON CtxXcXALoginTest_REPORT(MSMT_TIME);

DROP TABLE EsxLoginTest_REPORT;
CREATE TABLE EsxLoginTest_REPORT ( 
SESSION_KEY VARCHAR(128), 
TRGT_HOST VARCHAR(32),  
PORT_NO VARCHAR(32),  
MSMT_TIME DATETIME NOT NULL,
USERNAME VARCHAR(128) NOT NULL,
GUESTNAME VARCHAR(128) NOT NULL,
LOGIN_TIME DATETIME NOT NULL,
DURATION DECIMAL (20,4) NOT NULL,
ACTIVE_TIME DECIMAL (20,4) NOT NULL,
IDLE_TIME DECIMAL (20,4) NOT NULL,
CLIENT_IP_ADDRESS VARCHAR(128),
CLIENT_NAME VARCHAR(128),
CLIENT_ID VARCHAR(128),
CLIENT_CATEGORY VARCHAR(128),
CTX_STATE VARCHAR(128),
HDX_DISPLAY_MODE VARCHAR(128),
HDX_ACTIVE_ENCODER VARCHAR(128),
HDX_PROTOCOL VARCHAR(128),
ENCRYPTION_LEVEL VARCHAR(128),
NETSCALER_RPTNAME VARCHAR(128),
NETSCALER_IP_ADDRESS VARCHAR(128),
XENAPP_IP_ADDRESS VARCHAR(128),
ENDPOINT_IP_ADDRESS VARCHAR(128),
COUNTRY_NAME VARCHAR(128),
COUNTRY_CODE VARCHAR(128),
REGION VARCHAR(128),
CITY VARCHAR(128),
LATITUDE VARCHAR(128),
LONGITUDE VARCHAR(128),
LOGON_DURATION DECIMAL (20,4) NOT NULL,
ACTUAL_LOGON_DURATION DECIMAL (20,4) NOT NULL,
CPU_USED DECIMAL (20,4) NOT NULL,
ACTIVE_MEMORY DECIMAL (20,4) NOT NULL,
DATA_READS DECIMAL (20,4) NOT NULL,
DATA_WRITES DECIMAL (20,4) NOT NULL,
DATA_TRANSMITTED DECIMAL (20,4) NOT NULL,
DATA_RECEIVED DECIMAL (20,4) NOT NULL,
CLIENT_IPADDRESS  VARCHAR(32) NOT NULL,
CLIENT_VERSION VARCHAR(32) NOT NULL
);
CREATE INDEX IDX_EsxLoginTest_REPORT ON EsxLoginTest_REPORT(MSMT_TIME); 

DROP TABLE EsxLoginTest_REPORT_INSIDE;
CREATE TABLE EsxLoginTest_REPORT_INSIDE ( 
SESSION_KEY VARCHAR(128), 
TRGT_HOST VARCHAR(32),  
PORT_NO VARCHAR(32),  
MSMT_TIME DATETIME NOT NULL,
USERNAME VARCHAR(128) NOT NULL,
GUESTNAME VARCHAR(128) NOT NULL,
LOGIN_TIME DATETIME NOT NULL,
DURATION DECIMAL (20,4) NOT NULL,
ACTIVE_TIME DECIMAL (20,4) NOT NULL,
IDLE_TIME DECIMAL (20,4) NOT NULL,
CLIENT_IP_ADDRESS VARCHAR(128),
CLIENT_NAME VARCHAR(128),
CLIENT_ID VARCHAR(128),
CLIENT_CATEGORY VARCHAR(128),
CTX_STATE VARCHAR(128),
HDX_DISPLAY_MODE VARCHAR(128),
HDX_ACTIVE_ENCODER VARCHAR(128),
HDX_PROTOCOL VARCHAR(128),
ENCRYPTION_LEVEL VARCHAR(128),
NETSCALER_RPTNAME VARCHAR(128),
NETSCALER_IP_ADDRESS VARCHAR(128),
XENAPP_IP_ADDRESS VARCHAR(128),
ENDPOINT_IP_ADDRESS VARCHAR(128),
COUNTRY_NAME VARCHAR(128),
COUNTRY_CODE VARCHAR(128),
REGION VARCHAR(128),
CITY VARCHAR(128),
LATITUDE VARCHAR(128),
LONGITUDE VARCHAR(128),
LOGON_DURATION DECIMAL (20,4) NOT NULL,
ACTUAL_LOGON_DURATION DECIMAL (20,4) NOT NULL,
CPU_UTIL DECIMAL (20,4) NOT NULL,
TOTAL_PHY_MEM DECIMAL (20,4) NOT NULL,
PHYSICAL_MEM_UTILZE DECIMAL (20,4) NOT NULL,
PERCENT_BUSY DECIMAL (20,4) NOT NULL,
PERCENT_DISK_READS DECIMAL (20,4) NOT NULL,
PERCENT_DISK_WRITES DECIMAL (20,4) NOT NULL,
INCOMING_TRAFFIC DECIMAL (20,4) NOT NULL,
OUTGOING_TRAFFIC DECIMAL (20,4) NOT NULL,
SESSION_AVG_LATENCY DECIMAL (20,4) NOT NULL,
LAST_RECD_LATENCY DECIMAL (20,4) NOT NULL,
ICA_NWLATENCY DECIMAL (20,4) NOT NULL,
INPUT_SESSION_BANDWIDTH DECIMAL (20,4) NOT NULL,
OUTPUT_SESSION_BANDWIDTH DECIMAL (20,4) NOT NULL,
BROWSER_COUNT DECIMAL (20,4) NOT NULL,
AVG_CPU_UTIL DECIMAL (20,4) NOT NULL,
MEM_USED DECIMAL (20,4) NOT NULL,
CLIENT_IPADDRESS VARCHAR(32) NOT NULL,
CLIENT_VERSION VARCHAR(32) NOT NULL
);
CREATE INDEX IDX_EsxLoginTest_RPT_INSIDE ON EsxLoginTest_REPORT_INSIDE(MSMT_TIME);

DROP TABLE NodeGCtest;

CREATE TABLE NodeGCtest(
TRGT_HOST		VARCHAR(32)	NOT NULL,
PORT_NO			VARCHAR(32)	NOT NULL,
SITE_NAME		VARCHAR(64)	NOT NULL,
INFO			VARCHAR(128)	NOT NULL,
MSMT_HOST		VARCHAR(32)	NOT NULL,
MSMT_TIME		DATETIME	NOT NULL,
FullGC_count		DECIMAL(20,4)	NOT NULL,
FullGC_count_ST		VARCHAR(32)	NOT NULL,
IncGC_count		DECIMAL(20,4)	NOT NULL,
IncGC_count_ST		VARCHAR(32)	NOT NULL,
MinorGC_count		DECIMAL(20,4)	NOT NULL,
MinorGC_count_ST	VARCHAR(32)	NOT NULL,
FullGC_time		DECIMAL(20,4)	NOT NULL,
FullGC_time_ST		VARCHAR(32)	NOT NULL,
IncGC_time		DECIMAL(20,4)	NOT NULL,
IncGC_time_ST		VARCHAR(32)	NOT NULL,
MinorGC_time		DECIMAL(20,4)	NOT NULL,
MinorGC_time_ST		VARCHAR(32)	NOT NULL,
GC_time			DECIMAL(20,4)	NOT NULL,
GC_time_ST		VARCHAR(32)	NOT NULL,
GC_ticks		DECIMAL(20,4)	NOT NULL,
GC_ticks_ST		VARCHAR(32)	NOT NULL,
GC_released_mem		DECIMAL(20,4)	NOT NULL,
GC_released_mem_ST	VARCHAR(32)	NOT NULL,
Number_Of_Workers   	DECIMAL(20,4) 	NOT NULL,
Number_Of_Workers_ST	VARCHAR(32)	NOT NULL,
FullGC_Percentage 	DECIMAL(20,4)	NOT NULL,
FullGC_Percentage_ST 	VARCHAR(32)	NOT NULL,
IncGC_Percentage 	DECIMAL(20,4)	NOT NULL,
IncGC_Percentage_ST 	VARCHAR(32)	NOT NULL,
MinorGC_Percentage 	DECIMAL(20,4)	NOT NULL,
MinorGC_Percentage_ST 	VARCHAR(32)	NOT NULL,
TotalGC_Percentage	DECIMAL(20,4)	NOT NULL,
TotalGC_Percentage_ST	VARCHAR(32)	NOT NULL
);

CREATE INDEX IDX_NodeGCtest ON NodeGCtest(MSMT_TIME);
ALTER TABLE NodeGCtest ADD constraint PK_NodeGCtest PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST, MSMT_TIME);

DROP TABLE NodeGCtest_TREND;

CREATE TABLE NodeGCtest_TREND(
TRGT_HOST			VARCHAR(32)	NOT NULL,
PORT_NO				VARCHAR(32)	NOT NULL,
SITE_NAME			VARCHAR(64)	NOT NULL,
INFO				VARCHAR(128)	NOT NULL,
MSMT_HOST			VARCHAR(32)	NOT NULL,
MSMT_TIME			DATETIME	NOT NULL,
PERIOD				VARCHAR(32)	NOT NULL,
FullGC_count_MIN		DECIMAL(20,4)	NOT NULL,
FullGC_count_MAX		DECIMAL(20,4)	NOT NULL,
FullGC_count_STCNT		VARCHAR(32)	NOT NULL,
IncGC_count_MIN			DECIMAL(20,4)	NOT NULL,
IncGC_count_MAX			DECIMAL(20,4)	NOT NULL,
IncGC_count_STCNT		VARCHAR(32)	NOT NULL,
MinorGC_count_MIN		DECIMAL(20,4)	NOT NULL,
MinorGC_count_MAX		DECIMAL(20,4)	NOT NULL,
MinorGC_count_STCNT		VARCHAR(32)	NOT NULL,
FullGC_time_MIN			DECIMAL(20,4)	NOT NULL,
FullGC_time_MAX			DECIMAL(20,4)	NOT NULL,
FullGC_time_STCNT		VARCHAR(32)	NOT NULL,
IncGC_time_MIN			DECIMAL(20,4)	NOT NULL,
IncGC_time_MAX			DECIMAL(20,4)	NOT NULL,
IncGC_time_STCNT		VARCHAR(32)	NOT NULL,
MinorGC_time_MIN		DECIMAL(20,4)	NOT NULL,
MinorGC_time_MAX		DECIMAL(20,4)	NOT NULL,
MinorGC_time_STCNT		VARCHAR(32)	NOT NULL,
GC_time_MIN			DECIMAL(20,4)	NOT NULL,
GC_time_MAX			DECIMAL(20,4)	NOT NULL,
GC_time_STCNT			VARCHAR(32)	NOT NULL,
GC_ticks_MIN			DECIMAL(20,4)	NOT NULL,
GC_ticks_MAX			DECIMAL(20,4)	NOT NULL,
GC_ticks_STCNT			VARCHAR(32)	NOT NULL,
GC_released_mem_MIN		DECIMAL(20,4)	NOT NULL,
GC_released_mem_MAX		DECIMAL(20,4)	NOT NULL,
GC_released_mem_STCNT		VARCHAR(32)	NOT NULL,
Number_Of_Workers_MIN		DECIMAL(20,4)	NOT NULL,
Number_Of_Workers_MAX		DECIMAL(20,4)	NOT NULL,
Number_Of_Workers_STCNT		VARCHAR(32)	NOT NULL,
FullGC_Percentage_MIN 		DECIMAL(20,4)	NOT NULL,
FullGC_Percentage_MAX 		DECIMAL(20,4)	NOT NULL,
FullGC_Percentage_STCNT 	VARCHAR(32)	NOT NULL,
IncGC_Percentage_MIN		DECIMAL(20,4)	NOT NULL,
IncGC_Percentage_MAX		DECIMAL(20,4)	NOT NULL,
IncGC_Percentage_STCNT 		VARCHAR(32)	NOT NULL,
MinorGC_Percentage_MIN 		DECIMAL(20,4)	NOT NULL,
MinorGC_Percentage_MAX 		DECIMAL(20,4)	NOT NULL,
MinorGC_Percentage_STCNT 	VARCHAR(32)	NOT NULL,
TotalGC_Percentage_MIN		DECIMAL(20,4)	NOT NULL,
TotalGC_Percentage_MAX		DECIMAL(20,4)	NOT NULL,
TotalGC_Percentage_STCNT	VARCHAR(32)	NOT NULL
);


ALTER TABLE NodeGCtest_TREND ADD constraint PK_NodeGCtest_TREND PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST, MSMT_TIME,PERIOD);

DROP TABLE NodeGCtest_THRESH;

CREATE TABLE NodeGCtest_THRESH(
TRGT_HOST			VARCHAR(32)	NOT NULL,
PORT_NO				VARCHAR(32)	NOT NULL,
SITE_NAME			VARCHAR(64)	NOT NULL,
INFO				VARCHAR(128)	NOT NULL,
MSMT_HOST			VARCHAR(32)	NOT NULL,
MSMT_TIME_START			DATETIME	NOT NULL,
MSMT_TIME_END			DATETIME	NOT NULL,
FullGC_count_MIN		VARCHAR(256)	NOT NULL,
FullGC_count_MAX		VARCHAR(256)	NOT NULL,
IncGC_count_MIN			VARCHAR(256)	NOT NULL,
IncGC_count_MAX			VARCHAR(256)	NOT NULL,
MinorGC_count_MIN		VARCHAR(256)	NOT NULL,
MinorGC_count_MAX		VARCHAR(256)	NOT NULL,
FullGC_time_MIN			VARCHAR(256)	NOT NULL,
FullGC_time_MAX			VARCHAR(256)	NOT NULL,
IncGC_time_MIN			VARCHAR(256)	NOT NULL,
IncGC_time_MAX			VARCHAR(256)	NOT NULL,
MinorGC_time_MIN		VARCHAR(256)	NOT NULL,
MinorGC_time_MAX		VARCHAR(256)	NOT NULL,
GC_time_MIN			VARCHAR(256)	NOT NULL,
GC_time_MAX			VARCHAR(256)	NOT NULL,
GC_ticks_MIN			VARCHAR(256)	NOT NULL,
GC_ticks_MAX			VARCHAR(256)	NOT NULL,
GC_released_mem_MIN		VARCHAR(256)	NOT NULL,
GC_released_mem_MAX		VARCHAR(256)	NOT NULL,
Number_Of_Workers_MIN		VARCHAR(256)	NOT NULL,
Number_Of_Workers_MAX		VARCHAR(256)	NOT NULL,
FullGC_Percentage_MIN 		VARCHAR(256)	NOT NULL,
FullGC_Percentage_MAX 		VARCHAR(256)	NOT NULL,
IncGC_Percentage_MIN		VARCHAR(256)	NOT NULL,
IncGC_Percentage_MAX		VARCHAR(256)	NOT NULL,
MinorGC_Percentage_MIN 		VARCHAR(256)	NOT NULL,
MinorGC_Percentage_MAX 		VARCHAR(256)	NOT NULL,
TotalGC_Percentage_MIN		VARCHAR(256)	NOT NULL,
TotalGC_Percentage_MAX		VARCHAR(256)	NOT NULL
);


ALTER TABLE NodeGCtest_THRESH ADD constraint PK_NodeGCtest_THRESH PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST,MSMT_TIME_START);
CREATE INDEX IDX_NodeGCtest_THRESH ON NodeGCtest_THRESH (MSMT_HOST,MSMT_TIME_START,MSMT_TIME_END);
CREATE INDEX IDX_TH_NodeGCtest ON NodeGCtest_THRESH (MSMT_TIME_START);
CREATE INDEX IDX_TR_NodeGCtest ON NodeGCtest_TREND (MSMT_TIME,PERIOD);

DROP TABLE CtxNsVpnVsTest;
CREATE TABLE CtxNsVpnVsTest(
TRGT_HOST       varchar(32) NOT NULL,
PORT_NO         varchar(32) NOT NULL,
SITE_NAME       varchar(64) NOT NULL,
INFO            varchar(128) NOT NULL,
MSMT_HOST       varchar(32) NOT NULL,
MSMT_TIME       datetime NOT NULL,
SERVER_STATE DECIMAL(20,4) NOT NULL,
SERVER_STATE_ST varchar(32) NOT NULL,
REQ_DATA_RECEIVED DECIMAL(20,4) NOT NULL,
REQ_DATA_RECEIVED_ST varchar(32) NOT NULL,
RES_DATA_RECEIVED DECIMAL(20,4) NOT NULL,
RES_DATA_RECEIVED_ST varchar(32) NOT NULL,
REQ_RECEIVED DECIMAL(20,4) NOT NULL,
REQ_RECEIVED_ST varchar(32) NOT NULL,
RES_RECEIVED DECIMAL(20,4) NOT NULL,
RES_RECEIVED_ST varchar(32) NOT NULL,
CURRENT_USERS DECIMAL(20,4) NOT NULL,
CURRENT_USERS_ST varchar(32) NOT NULL,
MAX_USERS DECIMAL(20,4) NOT NULL,
MAX_USERS_ST varchar(32) NOT NULL,
CURR_TOT_USERS DECIMAL(20,4) NOT NULL,
CURR_TOT_USERS_ST varchar(32) NOT NULL,
UP_SERVERS DECIMAL(20,4) NOT NULL,
UP_SERVERS_ST varchar(32) NOT NULL,
DOWN_SERVERS DECIMAL(20,4) NOT NULL,
DOWN_SERVERS_ST varchar(32) NOT NULL,
PCT_OF_UP_SERVERS DECIMAL(20,4) NOT NULL,
PCT_OF_UP_SERVERS_ST varchar(32) NOT NULL);

CREATE INDEX IDX_CtxNsVpnVsTest ON CtxNsVpnVsTest(MSMT_TIME);
ALTER TABLE CtxNsVpnVsTest ADD constraint PK_CtxNsVpnVsTest PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST, MSMT_TIME);
DROP TABLE CtxNsVpnVsTest_TREND;
CREATE TABLE CtxNsVpnVsTest_TREND(
TRGT_HOST       varchar(32) NOT NULL,
PORT_NO         varchar(32) NOT NULL,
SITE_NAME       varchar(64) NOT NULL,
INFO            varchar(128) NOT NULL,
MSMT_HOST       varchar(32) NOT NULL,
MSMT_TIME       datetime NOT NULL,
PERIOD       	varchar(32) NOT NULL,
SERVER_STATE_MIN DECIMAL(20,4) NOT NULL,
SERVER_STATE_MAX DECIMAL(20,4) NOT NULL,
SERVER_STATE_STCNT varchar(32) NOT NULL,
REQ_DATA_RECEIVED_MIN DECIMAL(20,4) NOT NULL,
REQ_DATA_RECEIVED_MAX DECIMAL(20,4) NOT NULL,
REQ_DATA_RECEIVED_STCNT varchar(32) NOT NULL,
RES_DATA_RECEIVED_MIN DECIMAL(20,4) NOT NULL,
RES_DATA_RECEIVED_MAX DECIMAL(20,4) NOT NULL,
RES_DATA_RECEIVED_STCNT varchar(32) NOT NULL,
REQ_RECEIVED_MIN DECIMAL(20,4) NOT NULL,
REQ_RECEIVED_MAX DECIMAL(20,4) NOT NULL,
REQ_RECEIVED_STCNT varchar(32) NOT NULL,
RES_RECEIVED_MIN DECIMAL(20,4) NOT NULL,
RES_RECEIVED_MAX DECIMAL(20,4) NOT NULL,
RES_RECEIVED_STCNT varchar(32) NOT NULL,
CURRENT_USERS_MIN DECIMAL(20,4) NOT NULL,
CURRENT_USERS_MAX DECIMAL(20,4) NOT NULL,
CURRENT_USERS_STCNT varchar(32) NOT NULL,
MAX_USERS_MIN DECIMAL(20,4) NOT NULL,
MAX_USERS_MAX DECIMAL(20,4) NOT NULL,
MAX_USERS_STCNT varchar(32) NOT NULL,
CURR_TOT_USERS_MIN DECIMAL(20,4) NOT NULL,
CURR_TOT_USERS_MAX DECIMAL(20,4) NOT NULL,
CURR_TOT_USERS_STCNT varchar(32) NOT NULL,
UP_SERVERS_MIN DECIMAL(20,4) NOT NULL,
UP_SERVERS_MAX DECIMAL(20,4) NOT NULL,
UP_SERVERS_STCNT varchar(32) NOT NULL,
DOWN_SERVERS_MIN DECIMAL(20,4) NOT NULL,
DOWN_SERVERS_MAX DECIMAL(20,4) NOT NULL,
DOWN_SERVERS_STCNT varchar(32) NOT NULL,
PCT_OF_UP_SERVERS_MIN DECIMAL(20,4) NOT NULL,
PCT_OF_UP_SERVERS_MAX DECIMAL(20,4) NOT NULL,
PCT_OF_UP_SERVERS_STCNT varchar(32) NOT NULL);

ALTER TABLE CtxNsVpnVsTest_TREND ADD constraint PK_CtxNsVpnVsTest_TREND PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST, MSMT_TIME,PERIOD);
DROP TABLE CtxNsVpnVsTest_THRESH;
CREATE TABLE CtxNsVpnVsTest_THRESH(
TRGT_HOST       varchar(32) NOT NULL,
PORT_NO         varchar(32) NOT NULL,
SITE_NAME       varchar(64) NOT NULL,
INFO            varchar(128) NOT NULL
,MSMT_HOST       varchar(32) NOT NULL,
MSMT_TIME_START datetime NOT NULL,
MSMT_TIME_END   datetime NOT NULL,
SERVER_STATE_MIN VARCHAR(256) NOT NULL,
SERVER_STATE_MAX VARCHAR(256) NOT NULL,
REQ_DATA_RECEIVED_MIN VARCHAR(256) NOT NULL,
REQ_DATA_RECEIVED_MAX VARCHAR(256) NOT NULL,
RES_DATA_RECEIVED_MIN VARCHAR(256) NOT NULL,
RES_DATA_RECEIVED_MAX VARCHAR(256) NOT NULL,
REQ_RECEIVED_MIN VARCHAR(256) NOT NULL,
REQ_RECEIVED_MAX VARCHAR(256) NOT NULL,
RES_RECEIVED_MIN VARCHAR(256) NOT NULL,
RES_RECEIVED_MAX VARCHAR(256) NOT NULL,
CURRENT_USERS_MIN VARCHAR(256) NOT NULL,
CURRENT_USERS_MAX VARCHAR(256) NOT NULL,
MAX_USERS_MIN VARCHAR(256) NOT NULL,
MAX_USERS_MAX VARCHAR(256) NOT NULL,
CURR_TOT_USERS_MIN VARCHAR(256) NOT NULL,
CURR_TOT_USERS_MAX VARCHAR(256) NOT NULL,
UP_SERVERS_MIN VARCHAR(256) NOT NULL,
UP_SERVERS_MAX VARCHAR(256) NOT NULL,
DOWN_SERVERS_MIN VARCHAR(256) NOT NULL,
DOWN_SERVERS_MAX VARCHAR(256) NOT NULL,
PCT_OF_UP_SERVERS_MIN VARCHAR(256) NOT NULL,
PCT_OF_UP_SERVERS_MAX VARCHAR(256) NOT NULL);

ALTER TABLE CtxNsVpnVsTest_THRESH ADD constraint PK_CtxNsVpnVsTest_THRESH PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST,MSMT_TIME_START);
CREATE INDEX IDX_CtxNsVpnVsTest_THRESH ON CtxNsVpnVsTest_THRESH (MSMT_HOST,MSMT_TIME_START,MSMT_TIME_END);
CREATE INDEX IDX_TH_CtxNsVpnVsTest ON CtxNsVpnVsTest_THRESH (MSMT_TIME_START);
CREATE INDEX IDX_TR_CtxNsVpnVsTest ON CtxNsVpnVsTest_TREND (MSMT_TIME,PERIOD);

DROP TABLE CtxNsLicExpiryTest;
CREATE TABLE CtxNsLicExpiryTest(
TRGT_HOST       varchar(32) NOT NULL,
PORT_NO         varchar(32) NOT NULL,
SITE_NAME       varchar(64) NOT NULL,
INFO            varchar(128) NOT NULL,
MSMT_HOST       varchar(32) NOT NULL,
MSMT_TIME       datetime NOT NULL,
DAYS_TO_EXPIRE DECIMAL(20,4) NOT NULL,
DAYS_TO_EXPIRE_ST varchar(32) NOT NULL,
STATUS DECIMAL(20,4) NOT NULL,
STATUS_ST varchar(32) NOT NULL,
GRACE DECIMAL(20,4) NOT NULL,
GRACE_ST varchar(32) NOT NULL,
GRACE_LEFT DECIMAL(20,4) NOT NULL,
GRACE_LEFT_ST varchar(32) NOT NULL,
TOTAL_LICENSES DECIMAL(20,4) NOT NULL,
TOTAL_LICENSES_ST varchar(32) NOT NULL,
AVAILABLE_LICENSES DECIMAL(20,4) NOT NULL,
AVAILABLE_LICENSES_ST varchar(32) NOT NULL,
USED_LICENSES DECIMAL(20,4) NOT NULL,
USED_LICENSES_ST varchar(32) NOT NULL,
LICENSE_UTIL DECIMAL(20,4) NOT NULL,
LICENSE_UTIL_ST varchar(32) NOT NULL);

CREATE INDEX IDX_CtxNsLicExpiryTest ON CtxNsLicExpiryTest(MSMT_TIME);
ALTER TABLE CtxNsLicExpiryTest ADD constraint PK_CtxNsLicExpiryTest PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST, MSMT_TIME);
DROP TABLE CtxNsLicExpiryTest_TREND;
CREATE TABLE CtxNsLicExpiryTest_TREND(
TRGT_HOST       varchar(32) NOT NULL,
PORT_NO         varchar(32) NOT NULL,
SITE_NAME       varchar(64) NOT NULL,
INFO            varchar(128) NOT NULL,
MSMT_HOST       varchar(32) NOT NULL,
MSMT_TIME       datetime NOT NULL,
PERIOD       	varchar(32) NOT NULL,
DAYS_TO_EXPIRE_MIN DECIMAL(20,4) NOT NULL,
DAYS_TO_EXPIRE_MAX DECIMAL(20,4) NOT NULL,
DAYS_TO_EXPIRE_STCNT varchar(32) NOT NULL,
STATUS_MIN DECIMAL(20,4) NOT NULL,
STATUS_MAX DECIMAL(20,4) NOT NULL,
STATUS_STCNT varchar(32) NOT NULL,
GRACE_MIN DECIMAL(20,4) NOT NULL,
GRACE_MAX DECIMAL(20,4) NOT NULL,
GRACE_STCNT varchar(32) NOT NULL,
GRACE_LEFT_MIN DECIMAL(20,4) NOT NULL,
GRACE_LEFT_MAX DECIMAL(20,4) NOT NULL,
GRACE_LEFT_STCNT varchar(32) NOT NULL,
TOTAL_LICENSES_MIN DECIMAL(20,4) NOT NULL,
TOTAL_LICENSES_MAX DECIMAL(20,4) NOT NULL,
TOTAL_LICENSES_STCNT varchar(32) NOT NULL,
AVAILABLE_LICENSES_MIN DECIMAL(20,4) NOT NULL,
AVAILABLE_LICENSES_MAX DECIMAL(20,4) NOT NULL,
AVAILABLE_LICENSES_STCNT varchar(32) NOT NULL,
USED_LICENSES_MIN DECIMAL(20,4) NOT NULL,
USED_LICENSES_MAX DECIMAL(20,4) NOT NULL,
USED_LICENSES_STCNT varchar(32) NOT NULL,
LICENSE_UTIL_MIN DECIMAL(20,4) NOT NULL,
LICENSE_UTIL_MAX DECIMAL(20,4) NOT NULL,
LICENSE_UTIL_STCNT varchar(32) NOT NULL);

ALTER TABLE CtxNsLicExpiryTest_TREND ADD constraint PK_CtxNsLicExpiryTest_TREND PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST, MSMT_TIME,PERIOD);
DROP TABLE CtxNsLicExpiryTest_THRESH;
CREATE TABLE CtxNsLicExpiryTest_THRESH(
TRGT_HOST       varchar(32) NOT NULL,
PORT_NO         varchar(32) NOT NULL,
SITE_NAME       varchar(64) NOT NULL,
INFO            varchar(128) NOT NULL,
MSMT_HOST       varchar(32) NOT NULL,
MSMT_TIME_START datetime NOT NULL,
MSMT_TIME_END   datetime NOT NULL,
DAYS_TO_EXPIRE_MIN VARCHAR(256) NOT NULL,
DAYS_TO_EXPIRE_MAX VARCHAR(256) NOT NULL,
STATUS_MIN VARCHAR(256) NOT NULL,
STATUS_MAX VARCHAR(256) NOT NULL,
GRACE_MIN VARCHAR(256) NOT NULL,
GRACE_MAX VARCHAR(256) NOT NULL,
GRACE_LEFT_MIN VARCHAR(256) NOT NULL,
GRACE_LEFT_MAX VARCHAR(256) NOT NULL,
TOTAL_LICENSES_MIN VARCHAR(256) NOT NULL,
TOTAL_LICENSES_MAX VARCHAR(256) NOT NULL,
AVAILABLE_LICENSES_MIN VARCHAR(256) NOT NULL,
AVAILABLE_LICENSES_MAX VARCHAR(256) NOT NULL,
USED_LICENSES_MIN VARCHAR(256) NOT NULL,
USED_LICENSES_MAX VARCHAR(256) NOT NULL,
LICENSE_UTIL_MIN VARCHAR(256) NOT NULL,
LICENSE_UTIL_MAX VARCHAR(256) NOT NULL);

ALTER TABLE CtxNsLicExpiryTest_THRESH ADD constraint PK_CtxNsLicExpiryTest_THRESH PRIMARY KEY(TRGT_HOST,PORT_NO,SITE_NAME,INFO,MSMT_HOST,MSMT_TIME_START);
CREATE INDEX IDX_CtxNsLicExpiryTest_THRESH ON CtxNsLicExpiryTest_THRESH (MSMT_HOST,MSMT_TIME_START,MSMT_TIME_END);
CREATE INDEX IDX_TH_CtxNsLicExpiryTest ON CtxNsLicExpiryTest_THRESH (MSMT_TIME_START);
CREATE INDEX IDX_TR_CtxNsLicExpiryTest ON CtxNsLicExpiryTest_TREND (MSMT_TIME,PERIOD);

DROP TABLE RUM_ERROR_DETAILS;

CREATE TABLE RUM_ERROR_DETAILS 
(
	MSMT_TIME		DATETIME NOT NULL,
	REQUEST_DATE		DATETIME NOT NULL, 
	REQUEST_TIME_ZONE	VARCHAR(32) NOT NULL,
	ERROR_GUID		VARCHAR(128) NOT NULL,
	RUM_PARENT_GUID		VARCHAR(128) NOT NULL,
	RUM_BASE_GUID		VARCHAR(128) NOT NULL,
	ERROR_MESSAGE		VARCHAR(1024) NOT NULL,
	ERROR_FILENAME		VARCHAR(512) NOT NULL,
	ERROR_LINENUMBER	VARCHAR(8) NOT NULL,
	ERROR_COLUMNNUMBER	VARCHAR(8) NOT NULL,
	ERROR_STACK		VARBINARY(max) NOT NULL,
	ERROR_METADATA		VARCHAR(512) NOT NULL
);

ALTER TABLE RUM_ERROR_DETAILS ADD CONSTRAINT PK_RUM_ERROR_DETAILS PRIMARY KEY(ERROR_GUID,MSMT_TIME);

CREATE INDEX IDX1_RUM_ERROR_DETAILS on RUM_ERROR_DETAILS(RUM_PARENT_GUID);
