SQL dot notation

前端 未结 3 802
孤城傲影
孤城傲影 2020-11-29 06:54

Can someone please explain to me how SQL Server uses dot notation to identify
the location of a table? I always thought that the location is Database.dbo.Table

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 07:14

    This is a database schema. Full three-part name of a table is:

    databasename.schemaname.tablename
    

    For a default schema of the user, you can also omit the schema name:

    databasename..tablename
    

    You can also specify a linked server name:

    servername.databasename.schemaname.tablename
    

    You can read more about using identifiers as table names on MSDN:

    The server, database, and owner names are known as the qualifiers of the object name. When you refer to an object, you do not have to specify the server, database, and owner. The qualifiers can be omitted by marking their positions with a period. The valid forms of object names include the following:

    server_name.database_name.schema_name.object_name

    server_name.database_name..object_name

    server_name..schema_name.object_name

    server_name...object_name

    database_name.schema_name.object_name

    database_name..object_name

    schema_name.object_name

    object_name

    An object name that specifies all four parts is known as a fully qualified name. Each object that is created in Microsoft SQL Server must have a unique, fully qualified name. For example, there can be two tables named xyz in the same database if they have different owners.

    Most object references use three-part names. The default server_name is the local server. The default database_name is the current database of the connection. The default schema_name is the default schema of the user submitting the statement. Unless otherwise configured, the default schema of new users is the dbo schema.

提交回复
热议问题