数据库和模式之间的区别

Difference between database and schema(数据库和模式之间的区别)
本文介绍了数据库和模式之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL Server 中的数据库和架构有什么区别?两者都是表和数据的容器.

如果一个 Schema 被删除,那么包含在该 schema 中的所有表是否也被自动删除,还是在删除数据库时被删除?

解决方案

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

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.

EDITforadditionalquestion

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

这篇关于数据库和模式之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)