Double Dot table qualifier

前端 未结 2 908
迷失自我
迷失自我 2020-12-06 04:08

I am looking at a new database schema developed by an external vendor. There are two databases:

Database1
Database2

They have sent me an S

相关标签:
2条回答
  • 2020-12-06 04:47

    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

    0 讨论(0)
  • 2020-12-06 04:51

    Thanks to this dot, the default schema (dbo) is choosen for your query.

    When you have two databases it is required to give the full path to the table. If we have: Database1 schema: dbo, guest table dbo.A, guest: A Database2 schema: dbo, guest table dbo.B, guest: B

    if we create select statement like:

    select * from Database2..B

    We are selecting data from dbo.B table IF we would like to specify schema we need to refer as

    select * from Database2.schemaname.tablename
    

    EDIT: As colleagues pointed out, the default schema can be changed in database, however in this particular example it seems to be dbo :)

    0 讨论(0)
提交回复
热议问题