Home > Database > Mysql Tutorial > body text

What is the use of SQL mode IGNORE_SPACE?

WBOY
Release: 2023-09-11 14:13:14
forward
1279 people have browsed it

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

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

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

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!

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