Home > Database > Mysql Tutorial > Delimiter in MySQL?

Delimiter in MySQL?

WBOY
Release: 2023-08-26 16:13:02
forward
1602 people have browsed it

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)
Copy after login

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)
Copy after login

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

source:tutorialspoint.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template