About Schema
A database Schema is defined as a concept to logically group objects such as tables, views, stored procedures etc. Schema is a layout of the tables, data types, relations etc. act as a container of objects.
All objects within a schema must have a unique name and the name of the schema should also be unique in the database.
How to Create Schema:
Syntax:
- Create Schema Schema_Name <Schema element>Data types
Example
- CREATE TABLE Product1
- (
- iProductID INT IDENTITY(1,1)
- ,vProductName VARCHAR(100) NOT NULL
- ,vManfacturer VARCHAR(100) NOT NULL
- ,LastUpdated DATETIME DEFAULT GETDATE() ,
- PRIMARY KEY (iProductID, vManfacturer, vProductName)
-
- )
Example of Schema Created : A schema is created as in the following,
Once schema is created you can perform any SQL query like Update, Alter, Insert, Delete or Drop Schema.
Example: Here I used Insert Query.
- INSERT INTO Product1(vProductName, vManfacturer) VALUES('Television','Samsung')
How To Drop Schema: To drop schema follow the given syntax:
Syntax:
To view the Schema Change History follow the below steps:
Firstly, go to your Server
Object Explorer, then right click on selected server. Now select
Reports, after that select
Standard Reports, then click on
Schema Change History option as in the following screenshot,
A new query tab will be opened with all DDL Statements executed status with Server Name, Database Name, History (Since date & time), Object Name, Type, DDL Operation detail with Time as given below: