至少在我的本地实例上,当我创建表时,它们都带有“dbo.”前缀。为什么呢?


当前回答

DBO是SQL Server的默认模式。您可以创建自己的模式,以便更好地管理对象名称空间。作为最佳实践,我总是添加“DBO.”前缀,即使这不是必需的。在SQL中,大多数情况下显式是很好的。

其他回答

来自微软的东西(文档)

The dbo user is a special user principal in each database. All SQL Server administrators, members of the sysadmin fixed server role, sa login, and owners of the database, enter databases as the dbo user. The dbo user has all permissions in the database and cannot be limited or dropped. dbo stands for database owner, but the dbouser account is not the same as the db_owner fixed database role, and the db_owner fixed database role is not the same as the user account that is recorded as the owner of the database. The dbo user owns the dbo schema. The dbo schema is the default schema for all users, unless some other schema is specified. The dbo schema cannot be dropped. The dbo user owns the dbo schema. The dbo schema is the default schema for all users, unless some other schema is specified. The dbo schema cannot be dropped.

dbo是SQL Server的默认模式。您可以创建自己的模式,以便更好地管理对象名称空间。

它是SQL 2005的新特性,提供了一种简化的对象分组方法,特别是为了保护“组”中的对象。

下面的链接更深入地解释了它是什么,为什么我们要使用它:

理解SQL Server中owner和schema的区别

如果您正在使用Sql Server Management Studio,您可以通过浏览“数据库-您的数据库-安全性-模式”创建自己的模式。

使用脚本创建一个简单的方法如下(例如):

CREATE SCHEMA [EnterSchemaNameHere] AUTHORIZATION [dbo]

您可以使用它们对表进行逻辑分组,例如为“财务”信息创建一个模式,为“个人”数据创建另一个模式。你的表格将显示为:

金融。bankaccount 金融。交易 个人的。地址

而不是使用dbo的默认模式。

DBO是SQL Server的默认模式。您可以创建自己的模式,以便更好地管理对象名称空间。作为最佳实践,我总是添加“DBO.”前缀,即使这不是必需的。在SQL中,大多数情况下显式是很好的。