CREATE SCHEMA

Creates a schema in the current database. The CREATE SCHEMA transaction can also create tables and views within the new schema, and set GRANT, DENY, or REVOKE permissions on those objects.

Syntax
      CREATE SCHEMA schema_clause [ schema_element [ , ...n ] ]

   schema_clause:
      schema
      AUTHORIZATION owner
      schema AUTHORIZATION owner

   schema_elements: 
       table_definition
       view_definition
       grant_statement 
       revoke_statement
       deny_statement 
	  
Key:
   schema           The schema to create.
   owner            This owner may own other schemas but
                    may not use the current schema as its default schema.
   table_definition A CREATE TABLE statement
   view_definition  A CREATE VIEW statement
   grant_statement  A GRANT statement that grants permissions
   revoke_statement A REVOKE statement that revokes permissions
   deny_statement A DENY statement that denies permissions

Objects created by CREATE SCHEMA are created inside the schema that is being created.

Example

USE Mydatabase;
CREATE SCHEMA SecretPlans AUTHORIZATION BillG
CREATE TABLE takeover (company_id int, company_name varchar(100), cost int)
GRANT SELECT TO SteveB
DENY SELECT TO SteveJ;
GO

"In Europe everything is permanent, and in America everything is provisional. This is the great distinction which, if always kept in mind, will save a great deal of idle astonishment"~ Willian Dean Howells

Related commands:

ALTER SCHEMA
DROP SCHEMA
Equivalent Oracle command: CREATE SCHEMA


© Copyright SS64.com 1999-2014
Some rights reserved