10000個テーブルの作成と削除のテスト

戻る

# tables_test.pl # 10000個テーブルの作成と削除のテスト use strict; use DBI; my(%t,$n); #print "This is tables_test.pl.\n"; # データベースに連結(jié) $t{dsn} = "DBI:mysql:host=localhost;database=cookbook"; $t{dbh} = DBI->connect($t{dsn}, "cbuser", "cbpass") or die "Cannot connect to server\n"; $t{dbh}->do("SET NAMES utf8"); if(!$t{dbh}){ print "SQL read ERROR!\n"; exit; } $t{DEL} = 1; $t{end} = 10000; if ( $t{DEL} == 1 ) { for $n ( 1 .. $t{end} ) { $t{NO5} = sprintf("%06d",$n); $t{table} = 'a' . $t{NO5}; # 同名テーブルが存在している場合,削除 $t{sql} = 'DROP TABLE IF EXISTS ' . $t{table} . ';'; $t{dbh}->do($t{sql}); print "The table $t{table} is deleted.\n"; } } else { for $n ( 1 .. $t{end} ) { $t{NO5} = sprintf("%06d",$n); $t{table} = 'a' . $t{NO5}; # 同名テーブルが存在している場合,削除 $t{sql} = 'DROP TABLE IF EXISTS ' . $t{table} . ';'; $t{dbh}->do($t{sql}); # テーブルを作成する $t{sql} = 'CREATE TABLE ' . $t{table}; $t{sql} .= ' ('; $t{sql} .= 'id INT AUTO_INCREMENT,'; $t{sql} .= 'time date,'; $t{sql} .= 'PRIMARY KEY (id));'; $t{dbh}->do($t{sql}); print "The table $t{table} is created.\n"; } } $t{dbh}->disconnect; __END__;
戻る
湘潭市| 麦盖提县| 嘉鱼县| 乌海市| 鄯善县| 塘沽区| 滁州市| 镇雄县| 尼玛县| 威宁| 建德市| 东兰县| 凤庆县| 巴彦县| 南京市| 道孚县| 南川市| 潜江市| 文安县| 朝阳区| 海晏县| 饶平县| 衢州市| 时尚| 保德县| 田阳县| 桦甸市| 潞城市| 安庆市| 遂溪县| 鲁山县| 大兴区| 彩票| 纳雍县| 唐海县| 丰都县| 荃湾区| 徐州市| 大新县| 德昌县| 新民市|