---新建表
USE OMC_PUB;

---sysAlarmInfo
CREATE TABLE IF NOT EXISTS `sysAlarmInfo` (
  `sysTypeNo` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
  `sysNo` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `subSysNo` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `compCode` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `alarmCode` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `alarmTime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  `clearTime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  `clearMode` tinyint(4) NOT NULL DEFAULT 0,
  `clearInfo` varchar(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  `clearBy` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  `alertCheck` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  `alarmId` varchar(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  `alarmInfo` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  INDEX `clearTime`(`clearTime`) USING BTREE,
  INDEX `alarmTime`(`alarmTime`) USING BTREE,
  INDEX `sysTypeNo`(`sysTypeNo`) USING BTREE,
  INDEX `sysNo`(`sysNo`) USING BTREE,
  INDEX `subSysNo`(`subSysNo`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;

---sysAlarmEvent
CREATE TABLE IF NOT EXISTS `sysAlarmEvent`  (
  `sysTypeNo` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
  `sysNo` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `subSysNo` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `compCode` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `alarmCode` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `alarmTime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  `clearTime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  `clearMode` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0:clear 1:add 2:event',
  `clearInfo` varchar(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  `clearBy` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  `alertCheck` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  `alarmId` varchar(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  `alarmInfo` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  INDEX `clearTime`(`clearTime`) USING BTREE,
  INDEX `alarmTime`(`alarmTime`) USING BTREE,
  INDEX `sysTypeNo`(`sysTypeNo`) USING BTREE,
  INDEX `sysNo`(`sysNo`) USING BTREE,
  INDEX `subSysNo`(`subSysNo`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;

---omcPubVarConf
CREATE TABLE IF NOT EXISTS `omcPubVarConf` (
  `instance` tinyint(2) unsigned NOT NULL DEFAULT 0,
  `pubVarName` varchar(64)/*old*/ NOT NULL DEFAULT '',
  `pubVarValue` varchar(255)/*old*/ NOT NULL DEFAULT '',
  `remark` varchar(255)/*old*/ DEFAULT NULL,
  UNIQUE KEY `instance` (`instance`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (1, 'fieldName', 'AGrandTech', 'Field Name for this EMS');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (2, 'pssCardMinCount', 'cents', 'PPS Card Min Count');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (3, 'currency_decimal', '100', 'currency decimal');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (4, 'AucManagePwd', '123456', 'AucManagePwd');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (5, 'EirManagePwd', '123456', 'EirManagePwd');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (6, 'cdr_store_server', '', '(SFTP Format) user:password@ip>location');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (7, 'dailycdr_store_server', '', '(SFTP Format) user:password@ip>location');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (8, 'csta_store_server', '', '(SFTP Format) user:password@ip>location');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (9, 'automatic_scratch_card_time', '5', 'Automatic Scratch Card Time(0-23)');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (10, 'automatic_scratch_card_flag', '1', 'Automatic Scratch Card Flag(1:Enable 0:Disable)');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (11, 'alarmSmsNumberList', '', 'The moblie number be sended cretical alarm');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (12, 'getparam_from', '', 'get param form omc =0');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (13, 'getBssStatusAndAlarmTimer', '', 'Get Bss Status And Alarm');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (14, 'SMLOG_CONTENT_DECODE_FLAG', 'No', 'Decode the content of the SMLOG CDR(Yes/No)');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (15, 'SMLOG_CONTENT_SHOW_FLAG', 'No', 'Show the content of SMLOG CDR(Yes/No)');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (16, 'maxCOSNumber', '64', '');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (17, 'maxMoPrefixNumPerCOS', '300', '');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (18, 'globalFTPUserName', 'subsManager', 'For Import subscriber, download PPS Tarriff, backup MSS subs data and MSS Configuration Synchronization');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (19, 'globalFTPPassword', 'iammanager', 'For Import subscriber, download PPS Tarriff, backup MSS subs data and MSS Configuration Synchronization');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (20, 'HTTPSessionTimeout', '300', 'Unit:minute.');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (21, 'GenerateCDRFileInterval', '60', 'Unit:minute. Only support value(15,30,60)');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (22, 'ExternalRCM', '0', '0-disable, 1-enable');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (23, 'MTSMSCharge', '0', '1=enable, 0=disable');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (24, 'AlertSender', 'support@agrandtech.com', 'On behalf of the sending email address');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (25, 'AlertReceiver0', '', 'To receiver0');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (26, 'AlertReceiver1', '', 'To receiver1');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (27, 'AlertReceiver2', '', 'To receiver2');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (28, 'AlertReceiver3', '', 'To receiver3');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (29, 'AlertReceiver4', '', 'To receiver4');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (30, 'SMCLI_timeout', '60', 'The SMCLI timeout(1-720minutes)');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (31, 'ResourceThreshold', '95', 'The threshold unit is %');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (32, 'NeLicenseUser', 'agtuser', 'Order to opear hlr');
INSERT IGNORE INTO `OMC_PUB`.`omcPubVarConf`(`instance`, `pubVarName`, `pubVarValue`, `remark`) VALUES (33, 'NELicensePwd', 'admin123', 'Order to opear hlr');



CREATE TABLE IF NOT EXISTS `sysAlarmConf`  (
  `sysTypeNo` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `compCode` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `alarmCode` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `alarmDesc_1` varchar(100) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `alarmDesc_2` varchar(100) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `alarmType` smallint(3) UNSIGNED NOT NULL,
  `alarmLevel` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  `alarmNote_1` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
  `alarmNote_2` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
  `smsNumber` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  `level_1` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  `level_2` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  `instanceNo` smallint(3) UNSIGNED NOT NULL DEFAULT 0,
  `EventCode` smallint(4) UNSIGNED NOT NULL DEFAULT 9999,
  `SendAlert` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`sysTypeNo`, `compCode`, `alarmCode`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;

ALTER TABLE `OMC_PUB`.`sysAlarmConf` MODIFY COLUMN IF EXISTS `alarmType` smallint(3) UNSIGNED NOT NULL AFTER `alarmDesc_2`;












---CSTA_DB
USE CSTA_DB;
CREATE TABLE IF NOT EXISTS `smscSmppData`  (
  `key_sys_id` tinyint(3) NOT NULL DEFAULT 0,
  `key_type` tinyint(3) NOT NULL DEFAULT 0,
  `smppId` int(10) NOT NULL COMMENT 'smmpNum',
  `SMPP_to_SMSC_attempt` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_success` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_sysfail` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_userfail` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_smfail` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_byte` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_attempt` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_success` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_sysfail` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_userfail` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_smfail` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_byte` int(10) NOT NULL DEFAULT 0,
  `csta_datetime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`key_sys_id`, `key_type`, `smppId`, `csta_datetime`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Fixed;



CREATE TABLE IF NOT EXISTS `smscDetail`  (
  `key_sys_id` tinyint(2) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_success` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_byte` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_success` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_byte` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_success` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_byte` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_success` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_byte` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `csta_datetime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`key_sys_id`, `csta_datetime`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Fixed;


ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `MS_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `MS_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `MS_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `MS_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `MS_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `MS_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `PPS_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `PPS_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `PPS_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `PPS_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `PPS_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `PPS_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `VMS_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `VMS_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `VMS_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `VMS_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `VMS_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `VMS_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMPP_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMPP_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMPP_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMPP_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMPP_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMPP_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_MS_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_MS_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_MS_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_MS_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_MS_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_MS_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_PPS_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_PPS_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_PPS_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_PPS_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_PPS_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_PPS_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_VMS_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_VMS_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_VMS_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_VMS_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_VMS_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_VMS_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_SMPP_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_SMPP_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_SMPP_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_SMPP_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_SMPP_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SMSC_to_SMPP_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SM_bgn`;

ALTER TABLE `CSTA_DB`.`smscDetail` DROP COLUMN IF EXISTS `SM_end`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `key_sys_id`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_success` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_byte` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_success` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_byte` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_success` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_byte` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_success` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_success`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetail` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_byte` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_smfail`;


CREATE TABLE IF NOT EXISTS `smscDetailData`  (
  `key_sys_id` tinyint(2) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_success` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `MAP_to_SMSC_byte` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_success` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_MAP_byte` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_success` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SIP_to_SMSC_byte` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_success` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `SMSC_to_SIP_byte` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `csta_datetime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`key_sys_id`, `csta_datetime`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Fixed;


ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `MS_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `MS_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `MS_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `MS_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `MS_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `MS_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `PPS_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `PPS_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `PPS_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `PPS_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `PPS_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `PPS_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `VMS_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `VMS_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `VMS_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `VMS_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `VMS_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `VMS_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMPP_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMPP_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMPP_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMPP_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMPP_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMPP_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_MS_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_MS_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_MS_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_MS_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_MS_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_MS_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_PPS_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_PPS_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_PPS_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_PPS_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_PPS_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_PPS_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_VMS_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_VMS_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_VMS_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_VMS_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_VMS_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_VMS_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_SMPP_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_SMPP_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_SMPP_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_SMPP_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_SMPP_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SMSC_to_SMPP_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SM_bgn`;

ALTER TABLE `CSTA_DB`.`smscDetailData` DROP COLUMN IF EXISTS `SM_end`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `key_sys_id`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_success` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `MAP_to_SMSC_byte` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `MAP_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_success` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_MAP_byte` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_MAP_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_success` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SIP_to_SMSC_byte` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_smfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_attempt` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SIP_to_SMSC_byte`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_success` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_attempt`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_sysfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_success`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_userfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_sysfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_smfail` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_userfail`;

ALTER TABLE `CSTA_DB`.`smscDetailData` ADD COLUMN IF NOT EXISTS `SMSC_to_SIP_byte` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `SMSC_to_SIP_smfail`;


CREATE TABLE IF NOT EXISTS `spgwDetail`  (
  `key_sys_id` tinyint(2) UNSIGNED ZEROFILL NOT NULL DEFAULT 00,
  `attempted_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `attempted_ims_session_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_ims_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `attempted_delete_sess_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_delete_sess_sucess_num` int(10) NOT NULL DEFAULT 0,
  `attempted_create_bearer_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_create_bearer_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `attempted_ggsn_create_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_ggsn_create_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `attempted_ggsn_delete_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_ggsn_delete_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `ps_pagin_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `fail_ps_paging_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `ims_paging_num` int(10) NOT NULL DEFAULT 0,
  `fail_ims_paging_num` int(10) NOT NULL DEFAULT 0,
  `uplink_total_volume` bigint(10) UNSIGNED NOT NULL DEFAULT 0,
  `downlink_total_volume` bigint(10) UNSIGNED NOT NULL DEFAULT 0,
  `csta_datetime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`key_sys_id`, `csta_datetime`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Fixed;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `attemp_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `suc_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `actived_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `max_actived_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `cur_ps_active_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `max_cur_ps_active_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `cur_ims_active_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `max_cur_ims_active_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `ps_ip_addr_allocated`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `ps_ip_addr_free`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `ims_ip_addr_allocated`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `ims_ip_addr_free`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `ps_ccr_update_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `ps_ccr_update_time_interval`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `uplink_average_pack_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `downlink_average_pack_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `uplink_average_pack_size`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `downlink_average_pack_size`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `uplink_data_bit_rate`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `uplink_data_max_bit_rate`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `downlink_data_bit_rate`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `downlink_data_max_bit_rate`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `gtp_context_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `gtp_active_tunnrl_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `total_up_pktnum`;

ALTER TABLE `CSTA_DB`.`spgwDetail` DROP COLUMN IF EXISTS `total_down_pktnum`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `attempted_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `key_sys_id`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `succ_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `attempted_ims_session_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `succ_ims_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_ims_session_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `attempted_delete_sess_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_ims_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `succ_delete_sess_sucess_num` int(10) NOT NULL DEFAULT 0 AFTER `attempted_delete_sess_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `attempted_create_bearer_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_delete_sess_sucess_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `succ_create_bearer_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_create_bearer_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `attempted_ggsn_create_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_create_bearer_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `succ_ggsn_create_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_ggsn_create_pdp_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `attempted_ggsn_delete_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_ggsn_create_pdp_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `succ_ggsn_delete_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_ggsn_delete_pdp_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `uplink_total_volume` bigint(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `fail_ims_paging_num`;

ALTER TABLE `CSTA_DB`.`spgwDetail` ADD COLUMN IF NOT EXISTS `downlink_total_volume` bigint(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `uplink_total_volume`;



CREATE TABLE IF NOT EXISTS `spgwDetailData`  (
  `key_sys_id` tinyint(2) UNSIGNED ZEROFILL NOT NULL DEFAULT 00,
  `attempted_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `attempted_ims_session_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_ims_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `attempted_delete_sess_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_delete_sess_sucess_num` int(10) NOT NULL DEFAULT 0,
  `attempted_create_bearer_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_create_bearer_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `attempted_ggsn_create_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_ggsn_create_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `attempted_ggsn_delete_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `succ_ggsn_delete_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `ps_pagin_num` int(8) UNSIGNED NOT NULL DEFAULT 0,
  `fail_ps_paging_num` int(8) UNSIGNED NOT NULL DEFAULT 0,
  `ims_paging_num` int(10) NOT NULL DEFAULT 0,
  `fail_ims_paging_num` int(10) NOT NULL DEFAULT 0,
  `uplink_total_volume` bigint(32) UNSIGNED NOT NULL DEFAULT 0,
  `downlink_total_volume` bigint(32) UNSIGNED NOT NULL DEFAULT 0,
  `csta_datetime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`key_sys_id`, `csta_datetime`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Fixed;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `attemp_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `suc_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `actived_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `max_actived_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `cur_ps_active_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `max_cur_ps_active_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `cur_ims_active_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `max_cur_ims_active_user_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `ps_ip_addr_allocated`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `ps_ip_addr_free`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `ims_ip_addr_allocated`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `ims_ip_addr_free`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `ps_ccr_update_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `ps_ccr_update_time_interval`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `uplink_average_pack_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `downlink_average_pack_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `uplink_average_pack_size`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `downlink_average_pack_size`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `uplink_data_bit_rate`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `uplink_data_max_bit_rate`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `downlink_data_bit_rate`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `downlink_data_max_bit_rate`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `gtp_context_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `gtp_active_tunnrl_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `total_up_pktnum`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` DROP COLUMN IF EXISTS `total_down_pktnum`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `attempted_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `key_sys_id`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `succ_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `attempted_ims_session_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `succ_ims_sess_est_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_ims_session_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `attempted_delete_sess_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_ims_sess_est_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `succ_delete_sess_sucess_num` int(10) NOT NULL DEFAULT 0 AFTER `attempted_delete_sess_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `attempted_create_bearer_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_delete_sess_sucess_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `succ_create_bearer_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_create_bearer_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `attempted_ggsn_create_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_create_bearer_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `succ_ggsn_create_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_ggsn_create_pdp_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `attempted_ggsn_delete_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_ggsn_create_pdp_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `succ_ggsn_delete_pdp_num` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `attempted_ggsn_delete_pdp_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` MODIFY COLUMN IF EXISTS `ps_pagin_num` int(8) UNSIGNED NOT NULL DEFAULT 0 AFTER `succ_ggsn_delete_pdp_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` MODIFY COLUMN IF EXISTS `fail_ps_paging_num` int(8) UNSIGNED NOT NULL DEFAULT 0 AFTER `ps_pagin_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `uplink_total_volume` bigint(32) UNSIGNED NOT NULL DEFAULT 0 AFTER `fail_ims_paging_num`;

ALTER TABLE `CSTA_DB`.`spgwDetailData` ADD COLUMN IF NOT EXISTS `downlink_total_volume` bigint(32) UNSIGNED NOT NULL DEFAULT 0 AFTER `uplink_total_volume`;


CREATE TABLE IF NOT EXISTS `smscSmppData`  (
  `key_sys_id` tinyint(3) NOT NULL DEFAULT 0,
  `key_type` tinyint(3) NOT NULL DEFAULT 0,
  `smppId` int(10) NOT NULL COMMENT 'smmpNum',
  `SMPP_to_SMSC_attempt` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_success` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_sysfail` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_userfail` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_smfail` int(10) NOT NULL DEFAULT 0,
  `SMPP_to_SMSC_byte` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_attempt` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_success` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_sysfail` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_userfail` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_smfail` int(10) NOT NULL DEFAULT 0,
  `SMSC_to_SMPP_byte` int(10) NOT NULL DEFAULT 0,
  `csta_datetime` datetime(0) NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`key_sys_id`, `key_type`, `smppId`, `csta_datetime`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Fixed;

---删除表

----新增字段

---删除字段


---修改字段
---ALTER TABLE OMC_PUB.omcPubVarConf CHANGE COLUMN IF EXISTS `remark` remark1 VARCHAR(255);