mysql语句定界符[delimiter]

mysql默认的语句定界符为;,即:

mysql> select user, host from mysql.user;
+-------+-----------+
| user  | host      |
+-------+-----------+
| root  | 127.0.0.1 |
| root  | ::1       |
| berry | localhost |
| root  | localhost |
+-------+-----------+
4 rows in set (0.00 sec)

可以使用delimiter来指定语句定界符

mysql> delimiter //  --指定//为语句定界符
mysql> select user, host from mysql.user;
    -> //
+-------+-----------+
| user  | host      |
+-------+-----------+
| root  | 127.0.0.1 |
| root  | ::1       |
| berry | localhost |
| root  | localhost |
+-------+-----------+
4 rows in set (0.00 sec)

mysql> delimiter ;  //恢复到默认的语句定界符
mysql> select user, host from mysql.user;
+-------+-----------+
| user  | host      |
+-------+-----------+
| root  | 127.0.0.1 |
| root  | ::1       |
| berry | localhost |
| root  | localhost |
+-------+-----------+
4 rows in set (0.00 sec)

你可能感兴趣的:(mysql学习)