至少在我的本地实例上,当我创建表时,它们都带有“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中,大多数情况下显式是很好的。
推荐文章
- 确定记录是否存在的最快方法
- 从现有模式生成表关系图(SQL Server)
- 我如何循环通过一组记录在SQL Server?
- 数据库和模式的区别
- 如何在SQL Server中一次更改多个列
- 外键约束可能导致循环或多条级联路径?
- 如何选择每一行的列值不是独特的
- nvarchar(max)非文本
- 在SQL Server 2008 R2中重命名数据库时出错
- 将数据复制到另一个表中
- 如何在SQL中选择表的最后一条记录?
- 修改列,添加默认约束
- 在存储过程中使用“SET XACT_ABORT ON”有什么好处?
- 如何检查SQL Server文本列是否为空?
- 如何创建一个SQL Server函数“连接”多行从一个子查询到一个单独的分隔字段?