Database name restrictions

跟風遠走 提交于 2019-12-12 03:15:36

问题


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

To give an example:

database_name columnName TableName column_1

table.name

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

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


回答1:


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. The first character must be one of the following:

    • 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 (#).

      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.

      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 @@.

  2. Subsequent characters can include the following:

    • Letters as defined in the Unicode Standard 3.2.

    • Decimal numbers from either Basic Latin or other national scripts.

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

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

  4. Embedded spaces or special characters are not allowed.

  5. Supplementary characters are not allowed.

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.




回答2:


Please read this article about DataBase Naming Conventions:

https://launchbylunch.com/posts/2014/Feb/16/sql-naming-conventions/



来源:https://stackoverflow.com/questions/35506161/database-name-restrictions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!