What is Schema :As per Microsoft website :
A Schema is distinct namespace to facilitate the separation, management, and ownership of database objects.
How to create Schema by GUI:
Open the SSMS and you will be going to Database as Schema are objects in the database. Go to Security and then Go to Schema and Right Click and Choose New Schema as shown below.
Create Schema by using TSQL :
To create Schema in Database with default owner that is dbo, you can use below script.
--DatabaseName=TechBrothersIT USE [TechBrothersIT] GO --Create Schema Name =TB CREATE SCHEMA [TB] GO
Let's say If I have a user in TechbrothersIT Database with name [aamir] and I would like to create Schema TB with owner name =[aamir]. I can use below script.
--Database Name = TechBrothersIT USE [TechBrothersIT] GO --Create Schema TB with owner name =Aamir ( Database User) CREATE SCHEMA [TB] AUTHORIZATION [aamir] GOHow to Drop Schema from SQL Server Database:
1) By using GUI
we can right click on schema name in a database and hit Delete as shown below.
--Database Name = TechBrothersIT USE [TechBrothersIT] go --Drop Schema TB Drop Schema [TB]
Video Demo: What is Schema and how to Create/ Drop Schema