分类: Mysql/postgreSQL
2011-11-11 19:42:33
插入数据到数据库
cat sql.sh
#!/bin/sh
logins|awk '{print $1,$2,$3}'|while read aa bb cc
do
/usr/local/bin/mysql -h 183.23.155.155 -u root -p123 -e "insert into ccb.test2 value ('$aa','m','19800606','$bb','$cc','00000000')"
done
删除数据库中所有的数据
cat delsql.sh
#!/bin/sh
name=`/usr/local/bin/mysql -h 183.23.155.155 -u root -p123 -e "select * from ccb.test2" | sed 1d |awk '{print $1}' |uniq`
for i in $name
do
/usr/local/bin/mysql -h 183.23.155.155 -u root -p123 -e "delete from ccb.test2 where name='$i'"
done
#!/bin/sh
user=`seq -w 1 50000`
cat <
USE CCB;
INSERT INTO \`test\` (\`user\`, \`***\`) VALUES
EOF
for i in $user
do
echo \(\'DTch$i\', \'m\'\),>>ttttttt.sql
done
echo \(\'DTch50001\', \'m\'\)\; >>ttttttt.sql
/usr/local/bin/mysql -h 113.80.115.189 -u root -pzbhdpx