Home > Database > Mysql Tutorial > How Do Different Databases Handle Delimited Identifiers for Table and Column Names?

How Do Different Databases Handle Delimited Identifiers for Table and Column Names?

Barbara Streisand
Release: 2024-12-29 14:06:11
Original
951 people have browsed it

How Do Different Databases Handle Delimited Identifiers for Table and Column Names?

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

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

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

Other Databases

Most other databases, including standard SQL, use double-quotes as delimited identifiers:

SELECT * FROM "my_table";
Copy after login

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!

source:php.cn
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template