44 lines
1.2 KiB
Bash
44 lines
1.2 KiB
Bash
#!/bin/sh
|
|
|
|
table_name="test_db"
|
|
create_table="create table ${table_name}(user_code VARCHAR(20),user_name VARCHAR(20),user_desc VARCHAR(50));"
|
|
drop_table="drop table ${table_name};"
|
|
query_table="select count(*) from ${table_name};"
|
|
#isql="/opt/Kingbase/ES/V7/bin/isql"
|
|
|
|
if [ $1 = "create" ]
|
|
then
|
|
isql -h 127.0.0.1 -U SYSTEM -W 123456 -d $2 -p 54321 -c "${create_table}"
|
|
if [ $? -ne 0 ]
|
|
then
|
|
isql -h 127.0.0.1 -U SYSTEM -W 123456 -d $2 -p 54321 -c "${drop_table}"
|
|
isql -h 127.0.0.1 -U SYSTEM -W 123456 -d $2 -p 54321 -c "${create_table}"
|
|
fi
|
|
exit
|
|
elif [ $1 = "drop" ]
|
|
then
|
|
isql -h 127.0.0.1 -U SYSTEM -W 123456 -d $2 -p 54321 -c "${drop_table}"
|
|
exit
|
|
elif [ $1 = "insert" ]
|
|
then
|
|
res=1;num=1
|
|
while [ ${num} -lt 11 ]
|
|
do
|
|
insert_table="insert into ${table_name} values(${num},'test','test');"
|
|
isql -h 127.0.0.1 -U SYSTEM -W 123456 -d $2 -p 54321 -c "${insert_table}"
|
|
res=$?
|
|
let num=${num}+1
|
|
done
|
|
exit
|
|
elif [ $1 = "query" ]
|
|
then
|
|
# $isql -d OSRDB -c "${query_table}"
|
|
queryres=`isql -h 127.0.0.1 -U SYSTEM -W 123456 -d $2 -p 54321 -c "${query_table}"`
|
|
queryres1=${queryres##*-}
|
|
queryres2=${queryres1%%(*}
|
|
echo ${queryres2}
|
|
exit
|
|
else
|
|
echo "error"
|
|
fi
|