Commit dce7ff24 authored by yiwenshao's avatar yiwenshao

able to backup and restore

parent f3bef4b1
name="all.sql"
if [ $# = 1 ];then
name=$1
fi
mysqldump -uroot -pletmein -h127.0.0.1 -P3306 --no-create-info --compact tpcc1000 > $name
......@@ -16,11 +16,19 @@ function show_table_counts(){
for((i=1;i<$len;i++))
do
res=`mysql_command "SELECT COUNT(*) AS total_count FROM $1.${arr[$i]}"`
echo ${arr[$i]},$res
echo ${arr[$i]},$res >> res
done
}
show_table_counts $1
name="tpcc1000"
if [ $# = 1 ];then
name=$1
fi
show_table_counts $name
cat res
rm res
#res=`mysql_command 'show databases'`
#echo $res
......
drop table if exists warehouse;
SET sql_mode = '';
create table warehouse (
w_id smallint unsigned,
w_name varchar(10),
w_street_1 varchar(20),
w_street_2 varchar(20),
w_city varchar(20),
w_state char(2),
w_zip char(9),
w_tax integer unsigned,
w_ytd integer unsigned
) Engine=InnoDB;
drop table if exists district;
create table district (
d_id tinyint unsigned,
d_w_id smallint unsigned,
d_name varchar(10),
d_street_1 varchar(20),
d_street_2 varchar(20),
d_city varchar(20),
d_state char(2),
d_zip char(9),
d_tax integer unsigned,
d_ytd integer unsigned,
d_next_o_id int unsigned
) Engine=InnoDB;
drop table if exists customer;
create table customer (
c_id int unsigned,
c_d_id tinyint unsigned,
c_w_id smallint unsigned,
c_first varchar(16),
c_middle char(2),
c_last varchar(16),
c_street_1 varchar(20),
c_street_2 varchar(20),
c_city varchar(20),
c_state char(2),
c_zip char(9),
c_phone char(16),
c_since varchar(20),
c_credit char(2),
c_credit_lim bigint unsigned,
c_discount bigint unsigned,
c_balance bigint unsigned,
c_ytd_payment bigint unsigned,
c_payment_cnt smallint,
c_delivery_cnt smallint,
c_data VARCHAR(1000)) Engine=InnoDB;
drop table if exists history;
create table history (
h_c_id int,
h_c_d_id tinyint,
h_c_w_id smallint,
h_d_id tinyint,
h_w_id smallint,
h_date varchar(20),
h_amount integer unsigned,
h_data varchar(24) ) Engine=InnoDB;
drop table if exists new_orders;
create table new_orders (
no_o_id int not null,
no_d_id tinyint not null,
no_w_id smallint not null) Engine=InnoDB;
drop table if exists orders;
create table orders (
o_id int not null,
o_d_id tinyint not null,
o_w_id smallint not null,
o_c_id int,
o_entry_d varchar(20),
o_carrier_id tinyint,
o_ol_cnt tinyint,
o_all_local tinyint) Engine=InnoDB ;
drop table if exists order_line;
create table order_line (
ol_o_id int not null,
ol_d_id tinyint not null,
ol_w_id smallint not null,
ol_number tinyint not null,
ol_i_id int,
ol_supply_w_id smallint,
ol_delivery_d varchar(20),
ol_quantity tinyint,
ol_amount integer unsigned,
ol_dist_info char(24)) Engine=InnoDB ;
drop table if exists item;
create table item (
i_id int not null,
i_im_id int,
i_name varchar(24),
i_price integer unsigned,
i_data varchar(50)
) Engine=InnoDB;
drop table if exists stock;
create table stock (
s_i_id int not null,
s_w_id smallint not null,
s_quantity smallint,
s_dist_01 char(24),
s_dist_02 char(24),
s_dist_03 char(24),
s_dist_04 char(24),
s_dist_05 char(24),
s_dist_06 char(24),
s_dist_07 char(24),
s_dist_08 char(24),
s_dist_09 char(24),
s_dist_10 char(24),
s_ytd integer unsigned,
s_order_cnt smallint,
s_remote_cnt smallint,
s_data varchar(50)) Engine=InnoDB;
mysql -uroot -pletmein -h127.0.0.1 -e "drop database if exists tpcc1000"
mysql -uroot -pletmein -h127.0.0.1 -e "create database tpcc1000"
mysql -uroot -pletmein -h127.0.0.1 tpcc1000 < create_table.sql
files=`find ~/Insert/ -type f`
arrayfiles=($files)
#IFS=' ' read -r -a arrayfiles <<< "$files"
for data in ${arrayfiles[@]}
......
mysql -uroot -pletmein -h127.0.0.1 -P3306 -e "set @@GLOBAL.sql_mode = ''"
cd ../tls/tpcc-mysql/;./my_load.sh 1
path="Insert"
if [ $# = 1 ];then
path=$1
fi
files=`find $path -type f`
arrayfiles=($files)
for data in ${arrayfiles[@]}
do
ss="mysql -uroot -pletmein -h127.0.0.1 -P3306 tpcc1000 < $data"
eval $ss
echo $ss
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment