viewing paste Unknown #998 | SQL

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
DROP TABLE IF EXISTS `char_pk`;
CREATE TABLE `char_pk` (
  `char_id` INT(11) NOT NULL,
  `kill_count` INT(11) NOT NULL DEFAULT '0',
  `death_count` INT(11) NOT NULL DEFAULT '0',
  `score` INT(11) NOT NULL DEFAULT '0',
  PRIMARY KEY  (`char_id`)
) ENGINE=InnoDB;
 
DROP TABLE IF EXISTS `char_pvp`;
CREATE TABLE `char_pvp` (
  `char_id` INT(11) NOT NULL,
  `kill_count` INT(11) NOT NULL DEFAULT '0',
  `death_count` INT(11) NOT NULL DEFAULT '0',
  `score` INT(11) NOT NULL DEFAULT '0',
  PRIMARY KEY  (`char_id`)
) ENGINE=InnoDB;
 
DROP TABLE IF EXISTS `guild_rank`;
CREATE TABLE `guild_rank` (
  `guild_id` INT(11) NOT NULL,
  `castle_id` INT(11) NOT NULL,
  `capture` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `emperium` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `treasure` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `top_eco` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `top_def` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `invest_eco` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `invest_def` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `offensive_score` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `defensive_score` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `posesion_time` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `zeny_eco` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `zeny_def` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  
  `skill_battleorder` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `skill_regeneration` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `skill_restore` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `skill_emergencycall` INT(11) UNSIGNED NOT NULL DEFAULT '0',
 
  `off_kill` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `off_death` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `def_kill` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `def_death` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `ext_kill` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `ext_death` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `ali_kill` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `ali_death` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  
  PRIMARY KEY  (`guild_id`,`castle_id`),
  KEY `castle_id` (`castle_id`)
) ENGINE=InnoDB;
 
DROP TABLE IF EXISTS `ippremium`;
CREATE TABLE `ippremium` (
  `ip` VARCHAR(30) NOT NULL,
  `level` tinyint(2) DEFAULT '0',
  PRIMARY KEY  (`ip`)
) ENGINE=InnoDB;
 
DROP TABLE IF EXISTS `members`;
CREATE TABLE `members` (
  `member_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `nombre` VARCHAR(50) NOT NULL DEFAULT '',
  `email` VARCHAR(39) NOT NULL DEFAULT '',
  `sexo` enum('M','F') NOT NULL DEFAULT 'M',
  `pais` VARCHAR(20) NOT NULL DEFAULT '',
  `msn` VARCHAR(39) NOT NULL DEFAULT '',
  `icq` VARCHAR(15) NOT NULL DEFAULT '',
  `mpass` VARCHAR(40) NOT NULL DEFAULT '',
  `last_ip` VARCHAR(20) NOT NULL DEFAULT '0.0.0.0',
  `last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `acc_balance` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `services` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
  `banned` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  `ref_option` tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
  `ref_email` VARCHAR(39) NOT NULL DEFAULT 'none',
  `ref_points` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
  `mlevel` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY  (`member_id`)
) ENGINE=InnoDB;
 
--
-- Table structure for table `picklog` 
--
 
DROP TABLE IF EXISTS `rentstorage`;
CREATE TABLE `rentstorage` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `account_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `amount` SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
  `equip` mediumint(8) UNSIGNED NOT NULL DEFAULT '0',
  `identify` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
  `refine` tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
  `attribute` tinyint(4) UNSIGNED NOT NULL DEFAULT '0',
  `card0` SMALLINT(11) NOT NULL DEFAULT '0',
  `card1` SMALLINT(11) NOT NULL DEFAULT '0',
  `card2` SMALLINT(11) NOT NULL DEFAULT '0',
  `card3` SMALLINT(11) NOT NULL DEFAULT '0',
  `expire_time` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `serial` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `bound` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY  (`id`),
  KEY `account_id` (`account_id`)
) ENGINE=InnoDB;
 
--
-- Table structure for table `skillcooldown`
--
 
CREATE TABLE IF NOT EXISTS `skillcooldown` (
  `account_id` INT(11) UNSIGNED NOT NULL,
  `char_id` INT(11) UNSIGNED NOT NULL,
  `skill` SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
  `tick` INT(11) NOT NULL,
  KEY (`account_id`),
  KEY (`char_id`)
) ENGINE=InnoDB;
 
 
--
-- Item Serialization Update. Rev. 177 eAmod A
--
 
DROP TABLE IF EXISTS `item_serials`;
CREATE TABLE `item_serials` (
  `nameid` SMALLINT(5) UNSIGNED NOT NULL,
  `serial` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY  (`nameid`)
) ENGINE=InnoDB;
 
 
--
-- Tierra Domination Ranking. Rev 352 eAmod A
--
 
DROP TABLE IF EXISTS `char_bg`;
CREATE TABLE `char_bg` (
  `char_id` INT(11) NOT NULL,
  `top_damage` INT(11) NOT NULL DEFAULT '0',
  `damage_done` INT(11) NOT NULL DEFAULT '0',
  `damage_received` INT(11) NOT NULL DEFAULT '0',
  `skulls` INT(11) NOT NULL DEFAULT '0',
  `ti_wins` INT(11) NOT NULL DEFAULT '0',
  `ti_lost` INT(11) NOT NULL DEFAULT '0',
  `ti_tie` INT(11) NOT NULL DEFAULT '0',
  `eos_flags` INT(11) NOT NULL DEFAULT '0',
  `eos_bases` INT(11) NOT NULL DEFAULT '0',
  `eos_wins` INT(11) NOT NULL DEFAULT '0',
  `eos_lost` INT(11) NOT NULL DEFAULT '0',
  `eos_tie` INT(11) NOT NULL DEFAULT '0',
  `boss_killed` INT(11) NOT NULL DEFAULT '0',
  `boss_damage` INT(11) NOT NULL DEFAULT '0',
  `boss_flags` INT(11) NOT NULL DEFAULT '0',
  `boss_wins` INT(11) NOT NULL DEFAULT '0',
  `boss_lost` INT(11) NOT NULL DEFAULT '0',
  `boss_tie` INT(11) NOT NULL DEFAULT '0',
  `dom_bases` INT(11) NOT NULL DEFAULT '0',
  `dom_off_kills` INT(11) NOT NULL DEFAULT '0',
  `dom_def_kills` INT(11) NOT NULL DEFAULT '0',
  `dom_wins` INT(11) NOT NULL DEFAULT '0',
  `dom_lost` INT(11) NOT NULL DEFAULT '0',
  `dom_tie` INT(11) NOT NULL DEFAULT '0', 
  `td_kills` INT(11) NOT NULL DEFAULT '0',
  `td_deaths` INT(11) NOT NULL DEFAULT '0',
  `td_wins` INT(11) NOT NULL DEFAULT '0',
  `td_lost` INT(11) NOT NULL DEFAULT '0',
  `td_tie` INT(11) NOT NULL DEFAULT '0',
  `sc_stole` INT(11) NOT NULL DEFAULT '0',
  `sc_captured` INT(11) NOT NULL DEFAULT '0',
  `sc_droped` INT(11) NOT NULL DEFAULT '0',
  `sc_wins` INT(11) NOT NULL DEFAULT '0',
  `sc_lost` INT(11) NOT NULL DEFAULT '0',
  `sc_tie` INT(11) NOT NULL DEFAULT '0',
  `ctf_taken` INT(11) NOT NULL DEFAULT '0',
  `ctf_captured` INT(11) NOT NULL DEFAULT '0',
  `ctf_droped` INT(11) NOT NULL DEFAULT '0',
  `ctf_wins` INT(11) NOT NULL DEFAULT '0',
  `ctf_lost` INT(11) NOT NULL DEFAULT '0',
  `ctf_tie` INT(11) NOT NULL DEFAULT '0',
  `emperium_kill` INT(11) NOT NULL DEFAULT '0',
  `barricade_kill` INT(11) NOT NULL DEFAULT '0',
  `gstone_kill` INT(11) NOT NULL DEFAULT '0',
  `cq_wins` INT(11) NOT NULL DEFAULT '0',
  `cq_lost` INT(11) NOT NULL DEFAULT '0',
  `kill_count` INT(11) NOT NULL DEFAULT '0',
  `death_count` INT(11) NOT NULL DEFAULT '0',
  `win` INT(11) NOT NULL DEFAULT '0',
  `lost` INT(11) NOT NULL DEFAULT '0',
  `tie` INT(11) NOT NULL DEFAULT '0',
  `leader_win` INT(11) NOT NULL DEFAULT '0',
  `leader_lost` INT(11) NOT NULL DEFAULT '0',
  `leader_tie` INT(11) NOT NULL DEFAULT '0',
  `deserter` INT(11) NOT NULL DEFAULT '0',
  `score` INT(11) NOT NULL DEFAULT '0',
  `points` INT(11) NOT NULL DEFAULT '0',
  `sp_heal_potions` INT(11) NOT NULL DEFAULT '0',
  `hp_heal_potions` INT(11) NOT NULL DEFAULT '0',
  `yellow_gemstones` INT(11) NOT NULL DEFAULT '0',
  `red_gemstones` INT(11) NOT NULL DEFAULT '0',
  `blue_gemstones` INT(11) NOT NULL DEFAULT '0',
  `poison_bottles` INT(11) NOT NULL DEFAULT '0',
  `acid_demostration` INT(11) NOT NULL DEFAULT '0',
  `acid_demostration_fail` INT(11) NOT NULL DEFAULT '0',
  `support_skills_used` INT(11) NOT NULL DEFAULT '0',
  `healing_done` INT(11) NOT NULL DEFAULT '0',
  `wrong_support_skills_used` INT(11) NOT NULL DEFAULT '0',
  `wrong_healing_done` INT(11) NOT NULL DEFAULT '0',
  `sp_used` INT(11) NOT NULL DEFAULT '0',
  `zeny_used` INT(11) NOT NULL DEFAULT '0',
  `spiritb_used` INT(11) NOT NULL DEFAULT '0',
  `ammo_used` INT(11) NOT NULL DEFAULT '0',
  `rank_points` INT(11) NOT NULL DEFAULT '0',
  `rank_games` INT(11) NOT NULL DEFAULT '0',
  `ru_captures` INT(11) NOT NULL DEFAULT '0',
  `ru_wins` INT(11) NOT NULL DEFAULT '0',
  `ru_lost` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY  (`char_id`)
) ENGINE=InnoDB;
 
 
 
--
-- New Kill Log Update. Rev. 183 eAmod A
--
 
DROP TABLE IF EXISTS `char_bg_log`;
CREATE TABLE `char_bg_log` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `killer` VARCHAR(25) NOT NULL,
  `killer_id` INT(11) NOT NULL,
  `killed` VARCHAR(25) NOT NULL,
  `killed_id` INT(11) NOT NULL,
  `map` VARCHAR(11) NOT NULL DEFAULT '',
  `skill` INT(11) NOT NULL DEFAULT '0',
  PRIMARY KEY  (`id`),
  KEY `killer_id` (`killer_id`),
  KEY `killed_id` (`killed_id`)
) ENGINE=MyISAM;
 
DROP TABLE IF EXISTS `char_woe_log`;
CREATE TABLE `char_woe_log` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `killer` VARCHAR(25) NOT NULL,
  `killer_id` INT(11) NOT NULL,
  `killed` VARCHAR(25) NOT NULL,
  `killed_id` INT(11) NOT NULL,
  `map` VARCHAR(11) NOT NULL DEFAULT '',
  `skill` INT(11) NOT NULL DEFAULT '0',
  PRIMARY KEY  (`id`),
  KEY `killer_id` (`killer_id`),
  KEY `killed_id` (`killed_id`)
) ENGINE=MyISAM;
 
--
-- New Kill Log Update. Rev. 186 eAmod A
--
 
DROP TABLE IF EXISTS `char_woe`;
DROP TABLE IF EXISTS `char_wstats`;
CREATE TABLE `char_wstats` (
  `char_id` INT(11) NOT NULL,
  `kill_count` INT(11) NOT NULL DEFAULT '0',
  `death_count` INT(11) NOT NULL DEFAULT '0',
  `score` INT(11) NOT NULL DEFAULT '0',
  `top_damage` INT(11) NOT NULL DEFAULT '0',
  `damage_done` INT(11) NOT NULL DEFAULT '0',
  `damage_received` INT(11) NOT NULL DEFAULT '0',
  `emperium_damage` INT(11) NOT NULL DEFAULT '0',
  `guardian_damage` INT(11) NOT NULL DEFAULT '0',
  `barricade_damage` INT(11) NOT NULL DEFAULT '0',
  `gstone_damage` INT(11) NOT NULL DEFAULT '0',
  `emperium_kill` INT(11) NOT NULL DEFAULT '0',
  `guardian_kill` INT(11) NOT NULL DEFAULT '0',
  `barricade_kill` INT(11) NOT NULL DEFAULT '0',
  `gstone_kill` INT(11) NOT NULL DEFAULT '0',
  `sp_heal_potions` INT(11) NOT NULL DEFAULT '0',
  `hp_heal_potions` INT(11) NOT NULL DEFAULT '0',
  `yellow_gemstones` INT(11) NOT NULL DEFAULT '0',
  `red_gemstones` INT(11) NOT NULL DEFAULT '0',
  `blue_gemstones` INT(11) NOT NULL DEFAULT '0',
  `poison_bottles` INT(11) NOT NULL DEFAULT '0',
  `acid_demostration` INT(11) NOT NULL DEFAULT '0',
  `acid_demostration_fail` INT(11) NOT NULL DEFAULT '0',
  `support_skills_used` INT(11) NOT NULL DEFAULT '0',
  `healing_done` INT(11) NOT NULL DEFAULT '0',
  `wrong_support_skills_used` INT(11) NOT NULL DEFAULT '0',
  `wrong_healing_done` INT(11) NOT NULL DEFAULT '0',
  `sp_used` INT(11) NOT NULL DEFAULT '0',
  `zeny_used` INT(11) NOT NULL DEFAULT '0',
  `spiritb_used` INT(11) NOT NULL DEFAULT '0',
  `ammo_used` INT(11) NOT NULL DEFAULT '0',
  PRIMARY KEY  (`char_id`)
) ENGINE=InnoDB;
 
DROP TABLE IF EXISTS `skill_count`;
CREATE TABLE `skill_count` (
  `char_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `id` SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
  `count` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY  (`char_id`,`id`),
  KEY `char_id` (`char_id`)
) ENGINE=InnoDB;
 
DROP TABLE IF EXISTS `bg_skill_count`;
CREATE TABLE `bg_skill_count` (
  `char_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `id` SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
  `count` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY  (`char_id`,`id`),
  KEY `char_id` (`char_id`)
) ENGINE=InnoDB;
 
--
-- Achievement Database. Rev 337 eAmod A
--
 
DROP TABLE IF EXISTS `achievement`;
CREATE TABLE `achievement` (
  `id` INT(11) NOT NULL,
  `char_id` INT(11) NOT NULL,
  `completed` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  `count1` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `count2` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `count3` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `count4` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `count5` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY  (`char_id`,`id`)
) ENGINE=InnoDB;
 
 
delimiter '//'
CREATE PROCEDURE addcol(IN tablename VARCHAR(100), IN new_colname VARCHAR(100),IN valtype VARCHAR(10), IN defval VARCHAR(10) ) BEGIN
IF NOT EXISTS(
    SELECT * FROM information_schema.COLUMNS
    WHERE COLUMN_NAME='new_colname' AND TABLE_NAME='tablename'
    )
    THEN
        ALTER TABLE `tablename` ADD COLUMN `new_colname` 'valtype' UNSIGNED NOT NULL DEFAULT 'defval';
 
END IF;
END;
//
delimiter ';'
 
CALL addcol(`char`,`bg_gold`,'int(11)','0');
CALL addcol(`char`,`bg_silver`,'int(11)','0');
CALL addcol(`char`,`bg_bronze`,'int(11)','0');
CALL addcol(`char`,`playtime`,'bigint(20)','0');
CALL addcol(`char`,`faction_id`,'int(11)','0');
 
CALL addcol(`login`,`ipallow`,'varchar(20','*.*.*.*');
CALL addcol(`login`,`member_id`,'int(11)','0');
 
CALL addcol(`inventory`,`bound`,'tinyint(1)','0');
CALL addcol(`cart_inventory`,`bound`,'tinyint(1)','0');
CALL addcol(`storage`,`bound`,'tinyint(1)','0');
CALL addcol(`rentstorage`,`bound`,'tinyint(1)','0');
CALL addcol(`guild_storage`,`bound`,'tinyint(1)','0');
 
CALL addcol(`inventory`,`favorite`,'tinyint(1)','0');
CALL addcol(`cart_inventory`,`favorite`,'tinyint(1)','0');
CALL addcol(`storage`,`favorite`,'tinyint(1)','0');
CALL addcol(`rentstorage`,`favorite`,'tinyint(1)','0');
CALL addcol(`guild_storage`,`favorite`,'tinyint(1)','0');
 
CALL addcol(`auction`,`serial`,'int(11)','0');
CALL addcol(`mail`,`serial`,'int(11)','0');
CALL addcol(`inventory`,`serial`,'int(11)','0');
CALL addcol(`cart_inventory`,`serial`,'int(11)','0');
CALL addcol(`storage`,`serial`,'int(11)','0');
CALL addcol(`rentstorage`,`serial`,'int(11)','0');
CALL addcol(`guild_storage`,`serial`,'int(11)','0');
 
DROP PROCEDURE addcol;
Viewed 1620 times, submitted by lighta.