A schema is a logical container that groups objects of similar scope or ownership together. By default, the database owner (dbo
) schema is automatically created in a SQL Server database. Unless you specify otherwise, all SQL Server user objects are created in the database owner (dbo
) schema. You can define different default schemas for each user of the database. When you create a user database, SQL Server automatically creates these schemas: sys
, dbo
, INFORMATION_SCHEMA
, and guest
.
You can query the sys.schemas
system catalog view to see the schemas defined for the database. The following is the syntax to query this system catalog:
SELECT * FROM sys.schemas
You can also use SQL Server Management Studio 2014 to list the schemas defined for the database. To list the schemas defined for the database in SQL Server 2014 Management Studio, use the following steps:
Databases
folder.Security
folder.Schemas
folder to list the schemas defined for the database.You can use the CREATE SCHEMA
statement to create a schema. The following is the basic syntax of this command:
CREATE SCHEMA schema_name AUTHORIZATION user_or_role
We use the ALTER SCHEMA
statement to transfer objects from one schema to another. The following is the basic syntax of this command:
ALTER SCHEMA schema_name TRANSFER [ <entity_type> :: ] securable_name [;]
To delete a schema, we use the DROP SCHEMA
statement as follows:
DROP SCHEMA schema_name
The following are the steps to create a schema from SQL Server 2014 Management Studio:
Databases
folder.Security
folder and then right-click on the Schemas
folder.To delete a schema, right-click on the schema and choose Delete.
3.138.204.186