Delimited Identifiers: Variations Across Databases
Databases use a variety of techniques to quote table names, known as delimited identifiers. This is necessary to allow identifiers to include characters that would otherwise be interpreted as part of the query.
Most SQL databases use double-quotes for delimited identifiers:
SELECT * FROM "my table";
However, some databases use different characters.
MySQL uses back-quotes by default:
SELECT * FROM `my table`;
Microsoft SQL Server and Sybase use brackets by default:
SELECT * FROM [my table];
This table summarizes the default delimiter characters used by various databases:
Database | Default Delimiter |
---|---|
Standard SQL | Double-quotes |
MySQL | Back-quotes |
Microsoft SQL Server | Brackets |
Sybase | Brackets |
InterBase | None (requires setting dialect to 3) |
Firebird | None (requires setting dialect to 3) |
By understanding these differences, you can ensure that your SQL queries will work correctly across different database platforms.
The above is the detailed content of How Do Different Databases Handle Delimited Identifiers in SQL Queries?. For more information, please follow other related articles on the PHP Chinese website!