Home  >  Article  >  Database  >  What is the use of SQL mode IGNORE_SPACE?

What is the use of SQL mode IGNORE_SPACE?

WBOY
WBOYforward
2023-09-11 14:13:141242browse

What is the use of SQL mode IGNORE_SPACE?

The IGNORE_SPACE SQL mode can be used to modify how the parser handles whitespace-sensitive function names. The following are the situations when we can use IGNORE_SPACE SQL mode -

Case-1 - When IGNORE_SPACE SQL mode is disabled

Disable IGNORE_SPACE SQL mode, when there is no space between the name and the following brackets spaces, the parser will interpret the name as a function call. This also occurs when the function name is used in a non-expression context. It can be understood from the following query -

mysql> Create table SUM(Id Int);
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'SUM(Id Int)' at line 1

Now we can use spaces or put the name in quotes to remove the error and make the name be treated as an identifier. The following statement does the same thing -

Create table SUM (id int);
Create table ‘SUM’(id int);
Create table ‘SUM’ (id int);

Case 2 - When IGNORE_SPACE SQL mode is enabled

When we enable this mode, the parser relaxes that there cannot be a space between the function name and the function name The parentheses after the requirement. For example, with IGNORE_SPACE SQL mode enabled, the following two function calls are legal -

Select SUM(Salary) from employee;
Select SUM (Salary) from employee;

However, in this case, the parser treats the function name as a reserved word. This means that spaces after the name no longer represent identifiers.

The above is the detailed content of What is the use of SQL mode IGNORE_SPACE?. 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