What is a Schema in SQL Server 2005? Explain how to create a new Schema in a a Database.
A Schema can be used in many ways including: maintain a backup script to allow the user to create all users, groups, logins and permissions, to create/modify development code, to create an environment from it for testing. It acts as the container of all object in the database which can be used to recreate the database along with its objects intact. It is synonymous to a namespace.
Syntax:CREATE SCHEMA schema_name_clause [ <schema_element> [ ...n ] ]
<schema_name_clause> ::=
{
schema_name
| AUTHORIZATION owner_name
| schema_name AUTHORIZATION owner_name
}
<schema_element> ::=
{
table_definition | view_definition | grant_statement |
revoke_statement | deny_statement
}
What is a Schema in SQL Server 2005? Explain how to create a new Schema in a a Database.
A schema is used to create database objects. It can be created using CREATE SCHEMA statement. The objects created can be moved between schemas. Multiple database users can share a single default schema.
CREATE SCHEMA sample;
Table creation
Create table sample.sampleinfo
{
id int primary key,
name varchar(20)
}