SET NAMES 'GBK';
DELIMITER ;//

/*在所有摘要表中在CLI_MAC字段中建立索引，为提高摘要表建立索引的速度，首先清除摘要表数据*/
/*并发链接表增加CLI_DID字段，为提高摘要表建立索引的速度，首先清除表数据*/

/*并发链接表*/

TRUNCATE TABLE NETEMS.SM_SERVER_CONNECTIONS;
FLUSH TABLES;

/*并发链接表增加CLI_DID字段字段*/

ALTER TABLE NETEMS.SM_SERVER_CONNECTIONS ADD COLUMN CLI_DID BIGINT(20) AFTER VM_ID;


/*并发链接表CLI_DID上建立索引*/

ALTER TABLE NETEMS.SM_SERVER_CONNECTIONS ADD INDEX  IDX_SM_SERVER_CONNECTIONS_CLI_DID (CLI_DID);


/*在所有摘要表中在CLI_MAC字段中建立索引；为提高摘要表建立索引的速度，首先清除摘要表*/

/* 清除摘要表数据*/

FLUSH TABLES;
TRUNCATE TABLE SM_FETION;
FLUSH TABLES;
TRUNCATE TABLE SM_IM_ACTION;
FLUSH TABLES;
TRUNCATE TABLE SM_MAIL;
FLUSH TABLES;
TRUNCATE TABLE SM_MSN;
FLUSH TABLES;
TRUNCATE TABLE SM_MSN_FILE;
FLUSH TABLES;
TRUNCATE TABLE SM_QQ;
FLUSH TABLES;
TRUNCATE TABLE SM_QQ_FILE;
FLUSH TABLES;
TRUNCATE TABLE SM_RC_FTP;
FLUSH TABLES;
TRUNCATE TABLE SM_RC_TELNET;
FLUSH TABLES;
TRUNCATE TABLE SM_SERVER_CONNECTIONS;
FLUSH TABLES;
TRUNCATE TABLE SM_UK;
FLUSH TABLES;
TRUNCATE TABLE SM_USERD;
FLUSH TABLES;
TRUNCATE TABLE SM_WEB;
FLUSH TABLES;
TRUNCATE TABLE SM_WEB_FILE_TRANS;
FLUSH TABLES;
TRUNCATE TABLE SM_WEB_LOGON;
FLUSH TABLES;
TRUNCATE TABLE SM_WEB_MAIL_ATT;
FLUSH TABLES;
TRUNCATE TABLE SM_WEB_MAIL_BODY;
FLUSH TABLES;
TRUNCATE TABLE SM_WEB_MAIL_BRIEF;
FLUSH TABLES;
TRUNCATE TABLE SM_WEB_POST;
FLUSH TABLES;
TRUNCATE TABLE SM_WEB_SEARCH;
FLUSH TABLES;
TRUNCATE TABLE SM_WEIBO;
FLUSH TABLES;
TRUNCATE TABLE SM_YMSG;


/*在所有摘要表中在CLI_MAC字段中建立索引*/
ALTER TABLE  SM_FETION ADD INDEX  IDX_SM_FETION_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_IM_ACTION ADD INDEX  IDX_SM_IM_ACTION_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_MAIL ADD INDEX  IDX_SM_MAIL_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_MSN ADD INDEX  IDX_SM_MSN_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_MSN_FILE ADD INDEX  IDX_SM_MSN_FILE_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_QQ ADD INDEX  IDX_SM_QQ_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_QQ_FILE ADD INDEX  IDX_SM_QQ_FILE_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_RC_FTP ADD INDEX  IDX_SM_RC_FTP_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_RC_TELNET ADD INDEX  IDX_SM_RC_TELNET_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_SERVER_CONNECTIONS ADD INDEX  IDX_SM_SERVER_CONNECTIONS_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_UK ADD INDEX  IDX_SM_UK_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_USERD ADD INDEX  IDX_SM_USERD_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_WEB ADD INDEX  IDX_SM_WEB_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_WEB_FILE_TRANS ADD INDEX  IDX_SM_WEB_FILE_TRANS_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_WEB_LOGON ADD INDEX  IDX_SM_WEB_LOGON_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_WEB_MAIL_ATT ADD INDEX  IDX_SM_WEB_MAIL_ATT_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_WEB_MAIL_BODY ADD INDEX  IDX_SM_WEB_MAIL_BODY_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_WEB_MAIL_BRIEF ADD INDEX  IDX_SM_WEB_MAIL_BRIEF_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_WEB_POST ADD INDEX  IDX_SM_WEB_POST_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_WEB_SEARCH ADD INDEX  IDX_SM_WEB_SEARCH_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_WEIBO ADD INDEX  IDX_SM_WEIBO_CLI_MAC (CLI_MAC) ;
ALTER TABLE  SM_YMSG ADD INDEX  IDX_SM_YMSG_CLI_MAC (CLI_MAC) ;



UPDATE CFG_PRODUCT_VARIABLES SET VALUE='1.1.3.4' WHERE VARIABLE_NAME='DB_VERSION';