Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do table names in SQL Server start with "dbo"?

Tags:

sql-server

At least on my local instance, when I create tables, they are all prefixed with "dbo.". Why is that?

like image 425
pupeno Avatar asked Jun 30 '09 06:06

pupeno


People also ask

What is DBO in SQL Server table name?

The dbo schema is the default schema of every database. By default, users created with the CREATE USER Transact-SQL command have dbo as their default schema. The dbo schema is owned by the dbo user account. Users who are assigned the dbo as default schema don't inherit the permissions of the dbo user account.

Why we need to use DBO in SQL Server?

In SQL Server, the dbo or Database Owner is a server-level principal that has full access to the owned database. Microsoft's best practices recommend creating a discrete user, either an Active Directory domain user or group, or a SQL Server Authentication user, to use as the database owner.

What is the DBO user in SQL Server?

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.

How do I change DBO to schema in SQL Server?

To change the schema of a table by using SQL Server Management Studio, in Object Explorer, right-click on the table and then click Design. Press F4 to open the Properties window. In the Schema box, select a new schema. ALTER SCHEMA uses a schema level lock.


2 Answers

dbo is the default schema in SQL Server. You can create your own schemas to allow you to better manage your object namespace.

like image 186
Daniel Avatar answered Oct 21 '22 10:10

Daniel


If you are using Sql Server Management Studio, you can create your own schema by browsing to Databases - Your Database - Security - Schemas.

To create one using a script is as easy as (for example):

CREATE SCHEMA [EnterSchemaNameHere] AUTHORIZATION [dbo]

You can use them to logically group your tables, for example by creating a schema for "Financial" information and another for "Personal" data. Your tables would then display as:

Financial.BankAccounts Financial.Transactions Personal.Address

Rather than using the default schema of dbo.

like image 20
Fenton Avatar answered Oct 21 '22 10:10

Fenton