What is the difference between a schema and a table and a database?

后端 未结 14 1185
一整个雨季
一整个雨季 2020-12-07 07:18

This is probably a n00blike (or worse) question. But I\'ve always viewed a schema as a table definition in a database. This is wrong or not entirely correct. I don\'t rememb

14条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 07:45

    A schema is not a plan for the entire database. It is a plan/container for a subset of objects (ex.tables) inside a a database.

    This goes to say that you can have multiple objects(ex. tables) inside one database which don't neccessarily fall under the same functional category. So you can group them under various schemas and give them different user access permissions.

    That said, I am unsure whether you can have one table under multiple schemas. The Management Studio UI gives a dropdown to assign a schema to a table, and hence making it possible to choose only one schema. I guess if you do it with TSQL, it might create 2 (or multiple) different objects with different object Ids.

提交回复
热议问题