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

senior

What is database engine or storage engine? Mention few storage engines supported by MySQL and their use.

senior

What are some major differences between MySQL and Oracle database?

expert

Which is better for JOIN & INSERT - PostgreSQL or MySQL?

Bình luận

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

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