Schema In SQL Server
What is schema?
Hi friends, in this post we will learn about Schema in SQL Server. A schema is a container that holds tables, views, procedures, and so on. It is inside a database. The server is the outermost box, and the schema is the innermost box.
In earlier post we had discussed about SQL Server Operators, and Data Type in SQL Server.
User-Schema Separation
Schemas are no longer equivalent to database users , schema is now a distinct namespace that exists independently of the database user who created it. In other words, a schema is simply a container of objects. A schema can be owned by any user, and its ownership is transferable.
- Ownership of schemas and schema-scoped securables is transferable.
- Objects can be moved between schemas.
- A single schema can contain objects owned by multiple database users.
- Multiple database users can share a single default schema.
- Permissions on schemas and schema-contained securables can be managed with greater precision than in earlier releases.
- A schema can be owned by any database principal. This includes roles and application roles.
- A database user can be dropped without dropping objects in a corresponding schema.Default schema for a database is Dbo by default.
Create schema Query:-
create schema test go create table test.table1 (id int,name varchar(20)) go ----------------------Now Select Like this------------------------------- select * from test.table1