SQL Server: Can the same table exist in multiple schemas

前端 未结 5 1656
Happy的楠姐
Happy的楠姐 2021-02-20 05:26

I thought that the schemas are namespace instances and hence the same table created under 2 different schemas are 2 different objects from the perspective of the database. One o

5条回答
  •  既然无缘
    2021-02-20 05:50

    Yes, it can. Just try it

    CREATE SCHEMA OneSchema AUTHORIZATION dbo;
    CREATE SCHEMA TwoSchema AUTHORIZATION dbo;
    CREATE TABLE dbo.SomeTable (foo int);
    CREATE TABLE OneSchema.SomeTable (foo int);
    CREATE TABLE TwoSchema.SomeTable (foo int);
    

    A schema is both a securable and part of the "namespace"

提交回复
热议问题