首页 > 代码库 > MySQL之mysql客户端工作的批处理一些使用手法

MySQL之mysql客户端工作的批处理一些使用手法

通常我们会用mysql这个客户端程序来连接mysql库、这个通常是工作在交互式模式下的、如我们连接上mysql并执行如下操作:

mysql -uroot -h127.0.0.1 -P3306
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 96
Server version: 5.7.17-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 

这个时候我们就可以通过sql语句来完成与数据库的交互操作了如:

use tempdb;
Database changed
mysql> desc person;
+-------+------------+------+-----+---------+----------------+
| Field | Type       | Null | Key | Default | Extra          |
+-------+------------+------+-----+---------+----------------+
| id    | int(11)    | NO   | PRI | NULL    | auto_increment |
| name  | varchar(8) | YES  | UNI | NULL    |                |
+-------+------------+------+-----+---------+----------------+
2 rows in set (0.01 sec)

mysql> select * from person;
+----+------+
| id | name |
+----+------+
|  1 | a    |
|  2 | b    |
|  3 | c    |
+----+------+
3 rows in set (0.00 sec)

mysql> 

 

说了这么多只是为了把今天的主角引出来、这个就是mysql批处理模式

 

 

 

------

 

MySQL之mysql客户端工作的批处理一些使用手法