Creates a schema in the current database
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 within the schema.
Syntax
CREATE SCHEMA schema_name_clause <schema_name_clause> ::= { schema_name | schema_name AUTHORIZATION owner_name }
AUTHORIZATION owner_name
Specifies the name of the database-level principal that will own the schema. This principal may own other schemas, and may not use the current schema as its default schema.
1,example
CREATE LOGIN TestLoginName with password=‘J345#$)thb‘ ,DEFAULT_DATABASE = db_study go CREATE USER TestUserName FOR LOGIN TestLoginName WITH DEFAULT_SCHEMA = Test; go CREATE SCHEMA Test AUTHORIZATION TestUserName; go create table test.dt_test ( id int, code int ); go
时间: 2024-10-12 23:40:45