Home >Database >Mysql Tutorial >Delimiter in MySQL?

Delimiter in MySQL?

WBOY
WBOYforward
2023-08-26 16:13:021604browse

MySQL 中的分隔符?

You can use delimiters when you need to define stored procedures, functions, and create triggers. The default delimiter is semicolon.

You can change the delimiter to create procedures etc. However, if you are considering multiple statements, then you need to use different delimiters, such as $$ or //.

Here we have a table "GetRecordFromNow" in which the following are the records -

+---------------------+
| YourDateTime        |
+---------------------+
| 2018-12-07 22:30:18 |
| 2018-12-03 22:30:31 |
| 2018-12-02 22:30:41 |
| 2018-12-01 22:30:56 |
| 2018-12-03 22:31:04 |
+---------------------+
5 rows in set (0.00 sec)

The delimiter keyword is a function in the MySQL client. Here is a delimiter demonstration using the delimiter to call the above table -

mysql> delimiter //
mysql> create procedure DisplayALL()
   −> begin
   −> select *from GetRecordsFromNow;
   −> end
   −> //
Query OK, 0 rows affected (0.40 sec)

mysql> delimiter ;
mysql> call DisplayALL();
+---------------------+
| YourDateTime        |
+---------------------+
| 2018-12-07 22:30:18 |
| 2018-12-03 22:30:31 |
| 2018-12-02 22:30:41 |
| 2018-12-01 22:30:56 |
| 2018-12-03 22:31:04 |
+---------------------+
5 rows in set (0.07 sec)

Query OK, 0 rows affected (0.10 sec)

The above is the detailed content of Delimiter in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
Previous article:Using MySQL in batch modeNext article:Using MySQL in batch mode