Home >Database >Mysql Tutorial >利用MySQL客户端批量执行sql语句

利用MySQL客户端批量执行sql语句

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:25:06876browse

在OceanBase中,将sql语句写到my.sql文本文件中,然后用重定向命令将其批量导入到mysql客户端中执行即可。

[linuxidc.com @OceanBase ~]$ cat my.sql
create table x (a1 int, a2 int, a3 int, b1 int, b2 int, primary key(a1,a2,a3));
insert into x(a1,a2,a3,b1,b2) values (1,1,2,0,0);

[linuxidc.com @OceanBase ~]$ mysql -h1.32.36.29 -P4797 -uadmin -padmin [linuxidc.com @OceanBase ~]$ mysql -h1.32.36.29 -P4797 -uadmin -padmin
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 0
Server version: 5.5.1 OceanBase 0.4.1 (r11236) (Built Jan 5 2013 16:08:48)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select * from x;
+------+------+------+------+------+
| a1 | a2 | a3 | b1 | b2 |
+------+------+------+------+------+
| 1 | 1 | 2 | 0 | 0 |
+------+------+------+------+------+
1 row in set (0.00 sec)

在OceanBase中,将sql语句写到my.sql文本文件中,,然后用重定向命令将其批量导入到mysql客户端中执行即可。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Python 之SQLite3Next article:Oracle 对象统计信息