且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

数据库和模式之间的区别

更新时间:2023-11-20 14:50:10

数据库是主要容器,它包含数据和日志文件以及其中的所有架构.你总是备份一个数据库,它是一个独立的单元.

Schemas 就像数据库中的文件夹,主要用于将逻辑对象分组在一起,这使得通过 schema 设置权限变得容易.

编辑其他问题

删除模式 test1

消息 3729,级别 16,状态 1,第 1 行
无法删除架构test1",因为它正被对象copyme"引用.

您不能删除正在使用的架构.您必须首先从架构中删除所有对象.

相关阅读:

  1. SQL Server 架构有什么好处?
  2. MSDN:用户架构分离

What's the difference between a Database and a Schema in SQL Server? Both are the containers of tables and data.

If a Schema is deleted, then are all the tables contained in that schema also deleted automatically or are they deleted when the Database is deleted?

A database is the main container, it contains the data and log files, and all the schemas within it. You always back up a database, it is a discrete unit on its own.

Schemas are like folders within a database, and are mainly used to group logical objects together, which leads to ease of setting permissions by schema.

EDIT for additional question

drop schema test1

Msg 3729, Level 16, State 1, Line 1
Cannot drop schema 'test1' because it is being referenced by object 'copyme'.

You cannot drop a schema when it is in use. You have to first remove all objects from the schema.

Related reading:

  1. What good are SQL Server schemas?
  2. MSDN: User-Schema Separation