Câu hỏi phỏng vấn MySQL
Câu hỏi

What is the use of DELIMETER command in MySQL?

Câu trả lời

The DELIMITER command in MySQL is used to define a custom delimiter for SQL statements, primarily to facilitate the creation and execution of stored procedures, functions, and triggers. By default, MySQL uses the semicolon (;) as the delimiter to separate individual SQL statements. However, when defining stored procedures, functions, or triggers, which themselves contain multiple SQL statements separated by semicolons, using the default semicolon delimiter can cause issues. This is because MySQL could misinterpret the end of a single SQL statement within the stored procedure as the end of the entire procedure.

To avoid this problem, the DELIMITER command allows developers to temporarily change the delimiter to another character or sequence of characters, such as // or $$, that does not conflict with the semicolons used within the stored procedure's SQL statements. This custom delimiter marks the end of the entire stored procedure, function, or trigger definition, allowing it to be passed to the server as a single statement. Once the definition is complete, the delimiter can be changed back to the default semicolon, enabling normal SQL statement execution to resume.

The use of a custom delimiter is crucial when working with stored procedures, functions, or triggers in MyS...

middle

middle

Gợi ý câu hỏi phỏng vấn

junior

What is the difference between Data Definition Language (DDL) and Data Manipulation Language
(DML)?

middle

What is the difference between commands create database and create schema in MySQL?

expert

How many tables can a trigger associate to in MySQL? Can a trigger be associated to a view?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào