不同的数据库使用不同的名称引用吗?

2021-11-20 00:00:00 database mysql

例如mysql引用表名使用

For example, mysql quote table name using

SELECT * FROM `table_name`;

注意`

其他数据库是否曾经使用不同的字符来引用他们的表名

Does other database ever use different char to quote their table name

推荐答案

引号的这种用法称为分隔标识符.它是 SQL 的重要组成部分,否则您不能使用以下标识符(例如表名和列名):

This use of quotes is called delimited identifiers. It's an important part of SQL because otherwise you can't use identifiers (e.g. table names and column names) that:

  • 包括空格:我的表格"
  • 包括特殊字符和标点符号:my-table"
  • 包括国际字符:私のテーブル"
  • 区分大小写:MyTable"
  • 匹配 SQL 关键字:表"

标准 SQL 语言使用双引号作为分隔标识符:

The standard SQL language uses double-quotes for delimited identifiers:

SELECT * FROM "my table";

MySQL 默认使用反引号.MySQL 可以使用标准的双引号:

MySQL uses back-quotes by default. MySQL can use standard double-quotes:

SELECT * FROM `my table`;
SET SQL_MODE=ANSI_QUOTES;
SELECT * FROM "my table";

Microsoft SQL Server 和 Sybase 默认使用方括号.他们都可以这样使用标准的双引号:

Microsoft SQL Server and Sybase uses brackets by default. They can both use standard double-quotes this way:

SELECT * FROM [my table];
SET QUOTED_IDENTIFIER ON;
SELECT * FROM "my table";

InterBase 和 Firebird 需要将 SQL 方言设置为 3 以支持分隔标识符.

InterBase and Firebird need to set the SQL dialect to 3 to support delimited identifiers.

大多数其他品牌的数据库正确使用双引号.

Most other brands of database use double-quotes correctly.

相关文章