AndroMDA

ALWAYS FINDING RIGHT PEOPLE

Create a Database Schema

Before you Begin

Limitations and Restrictions

The new schema is owned by one of the following database-level principals: database user, database role or application role. Objects created within a schema are owned by the owner of the schema and have a NULL principal_id in sys.objects. Ownership of schema-contained objects can be transferred to any database-level principal, but the schema owner always retains control permission on objects with in the schema.

When creating a database object, if you specify a valid domain principal (user or group) as the object owner, the domain principal will be added to the database as a schema. The new schema will be owned by that domain principal.

Security

Permissions

A requirement is CREATE SCHEMA permission on the database.

To specify another user as an owner of the schema being created, the caller must have a IMPERSONATE permission on that user. If the database role is specified as an owner, the caller must have one of the following: a membership in the role or ALTER permission on the role.

Using SQL Server Management Studio

To create a schema

1. In Object Explorer, expand the Databases folder.
2. Expand the database and wish to create the new database schema.
3. Right click this Security folder, point to New, and select Schema.
4. In the Schema - New dialog box, on the General page, enter a name for the new schema in the Schema name box.
5. In the Schema owner box, enter the name of the database user or roll to own the schema. Alternately, click Search to open the Search Roles and Users dialogue box.
6. Click OK

Additional options

The Schema-New dialog box also offers options on two additional pages: Permissions and Extended Properties.

The Permissions page lists all possible securables and the permissions on those securable that can be granted to the login.
The Extended properties page allows you to add custom properties to database users.

Using Transact - SQL

To create a schema

1. In Object Explorer, connect to an instance of Database Engine.
2. On the Standard bar, click New Query.
3. Copy and paste the following example into the query window and click Execute.


USE AdventureWorks2012;

GO

- Creates the schema Sprockets owned by Annik that contains table NineProngs.
- The statement grants SELECT to Mandar and denies SELECT to Prasanna.

CREATE SCHEMA Sprockets AUTHORIZATION Annik
CREATE TABLE NineProngs (source int, cost int, partnumber int)
GRANT SELECT ON SCHEMA::Sprockets TO Mandar
DENY SELECT ON SCHEMA::Sprockets TO Prasanna;

GO


More about you can read in Database Schema books. You can find them on Amazon, Overstock or Target. Check prices on all of them. With target coupon code it might be the best deal to buy books.