数据库名称限制 [英] Database name restrictions

查看:270
本文介绍了数据库名称限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道数据库中数据库,表和列的命名限制是什么? (MySQL,MSSQL,Oracle等)

What I wonder what are the database, table, and column naming restrictions in databases? (MySQL, MSSQL, Oracle, etc.)

举个例子:

数据库名称 columnName 表名 column_1

database_name columnName TableName column_1

table.name

table.name

我们可以使用符号"_",并且数字等也没有问题.

we can use the symbol "_" and also there no problem with numbers, etc.

但我们不能使用."当我们命名时.

but we can not use "." when we are naming.

推荐答案

常规标识符格式的规则取决于数据库兼容性级别.可以使用ALTER DATABASE设置此级别.当兼容性级别为100时,适用以下规则:

The rules for the format of regular identifiers depend on the database compatibility level. This level can be set by using ALTER DATABASE . When the compatibility level is 100 , the following rules apply:

  1. 第一个字符必须为以下字符之一:

  1. The first character must be one of the following:

  • 由Unicode标准3.2定义的字母.字母的Unicode定义包括从a到z,从A到Z的拉丁字符,以及其他语言的字母字符.

  • A letter as defined by the Unicode Standard 3.2. The Unicode definition of letters includes Latin characters from a through z, from A through Z, and also letter characters from other languages.

下划线(_),符号(@)或数字符号(#).

The underscore (_), at sign (@), or number sign (#).

在标识符开头的某些符号在SQL Server中具有特殊含义.以at符号开头的常规标识符始终表示局部变量或参数,不能用作任何其他类型的对象的名称.以数字符号开头的标识符表示临时表或过程.以双数字符号(##)开头的标识符表示全局临时对象.尽管可以使用数字符号或双数字符号字符来开头其他类型的对象的名称,但我们不建议您这样做.

Certain symbols at the beginning of an identifier have special meaning in SQL Server. A regular identifier that starts with the at sign always denotes a local variable or parameter and cannot be used as the name of any other type of object. An identifier that starts with a number sign denotes a temporary table or procedure. An identifier that starts with double number signs (##) denotes a global temporary object. Although the number sign or double number sign characters can be used to begin the names of other types of objects, we do not recommend this practice.

某些Transact-SQL函数的名称以符号(@@)开头的双开头.为避免与这些功能混淆,请勿使用以@@开头的名称.

Some Transact-SQL functions have names that start with double at signs (@@). To avoid confusion with these functions, you should not use names that start with @@.

后续字符可以包括以下内容:

Subsequent characters can include the following:

  • Unicode标准3.2中定义的字母.

  • Letters as defined in the Unicode Standard 3.2.

基本拉丁文或其他国家文字的十进制数字.

Decimal numbers from either Basic Latin or other national scripts.

at符号,美元符号($),数字符号或下划线.

The at sign, dollar sign ($), number sign, or underscore.

标识符不得为Transact-SQL保留字. SQL Server保留保留字的大写和小写版本.

The identifier must not be a Transact-SQL reserved word. SQL Server reserves both the uppercase and lowercase versions of reserved words.

不允许包含空格或特殊字符.

Embedded spaces or special characters are not allowed.

不允许使用补充字符.

在Transact-SQL语句中使用标识符时,不符合这些规则的标识符必须用双引号或括号定界.

When identifiers are used in Transact-SQL statements, the identifiers that do not comply with these rules must be delimited by double quotation marks or brackets.

这篇关于数据库名称限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆