- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Delimiters in MySQL?
Delimiters can be used when you need to define the stored procedures, function as well as to create triggers. The default delimiter is semicolon.
You can change the delimiters to create procedures and so on. However, but if you are considering multiple statements, then you need to use different delimiters like $$ or //.
Here we have a table “GetRecordFromNow” wherein 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 type of function in MySQL client. Here is the demo of delimiter that calls the above table using delimiter −
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)
Advertisements