sql命令

1、mysql清空数据表

SELECT CONCAT('TRUNCATE ',TABLE_NAME ,' ;') FROM TABLES WHERE  TABLE_SCHEMA = 'basketball' AND (TABLE_NAME LIKE 'user_%' OR TABLE_NAME ='user' OR TABLE_NAME ='player' )

导入sql脚本文件中,登陆后使用source命令执行

2、实现不同主机数据库覆盖

/usr/local/mysql/bin/mysqldump -uroot -proot basketball sys_ba >/root/projects/zhangbin/test/bk.sql
/usr/local/mysql/bin/mysql -h 192.168.0.9 -uroot -proot test</root/projects/zhangbin/test/bk.sql
3、mysql 短线重连

<property name="url" value="jdbc:mysql://192.168.1.139:3306/gm?characterEncoding=utf-8&amp;autoReconnect=true"></property>

<property name="defaultAutoCommit" value="true"></property>
       <property name="testOnBorrow" value="true"></property>

你可能感兴趣的:(sql相关命令)