A schema is a collection of database objects like tables, triggers, stored procedures, etc. A schema is connected with a user which is known as the schema owner. Database may have one or more schema.
SQL Server have some built-in schema, for example: dbo, guest, sys, and INFORMATION_SCHEMA.
dbo is default schema for a new database, owned by dbo user. While creating a new user with CREATE USER command, user will take dbo as its default schema.
CREATE SCHEMA statement used to create a new schema in current database.
CREATE SCHEMA schemaname [AUTHORIZATION ownername] GO
CREATE SCHEMA geeks_sch; GO
To select SQL Server SCHEMA :
To list all schema in the current database, use query as shown below :
SELECT * FROM sys.schemas
Create objects for the schema :
To create a new table named Geektab in the geeks_sch schema :
CREATE TABLE schemaname.tablename( values... );
CREATE TABLE geeks_sch.Geektab( G_id INT PRIMARY KEY IDENTITY, Name VARCHAR(200), DOJ DATETIME2 NOT NULL );
- Create, Alter and Drop schema in MS SQL Server
- DROP SCHEMA in SQL Server
- ALTER SCHEMA in SQL Server
- Create login in SQL Server
- Create Database in MS SQL Server
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- Relation Schema in DBMS
- Delete statement in MS SQL Server
- SQL Server Mathematical functions (SQRT, PI, SQUARE, ROUND, CEILING & FLOOR)
- SQL Server Identity
- SQL SERVER | Conditional Statements
- SQL Server | STUFF() Function
- SQL Server | SERVERPROPERTY()
- Mean and Mode in SQL Server
- Allow only alphabets in column in SQL Server
- SQL SERVER | IN Condition
- Reverse Statement Word by Word in SQL server
- Copy tables between databases in SQL Server using Import-and-Export Wizard
- Difference between MySQL and MS SQL Server
- Comparisons between Oracle vs SQL Server
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.