Different Name Quotes in Databases
Databases employ delimited identifiers to allow the use of table and column names that may contain characters such as whitespace, special characters, international characters, and case-sensitive identifiers. Different databases use various characters for these delimiters.
MySQL
MySQL uses back-quotes by default. However, it supports standard double-quotes when the SQL_MODE is set to ANSI_QUOTES:
SELECT * FROM `my_table`; // MySQL default SELECT * FROM "my_table"; // MySQL with ANSI_QUOTES
Microsoft SQL Server and Sybase
These databases use brackets as default delimiters. They also support double-quotes using the following setting:
SELECT * FROM [my_table]; // Default SET QUOTED_IDENTIFIER ON; SELECT * FROM "my_table";
InterBase and Firebird
These databases require setting the SQL dialect to 3 to use delimited identifiers.
SET SQL DIALECT 3; // Enable delimited identifiers SELECT * FROM "my_table";
Other Databases
Most other databases, including standard SQL, use double-quotes as delimited identifiers:
SELECT * FROM "my_table";
By using delimited identifiers, database users can create table and column names that are not otherwise supported by SQL.
The above is the detailed content of How Do Different Databases Handle Delimited Identifiers for Table and Column Names?. For more information, please follow other related articles on the PHP Chinese website!