sql server - Difference between database and schema

ID : 20171

viewed : 18

Tags : sql-serverdatabasesql-server-2005database-schemasql-server

Top 5 Answer for sql server - Difference between database and schema

vote vote


A database is the main container, it contains the data and log files, and all the schemas within it. You always back up a database, it is a discrete unit on its own.

Schemas are like folders within a database, and are mainly used to group logical objects together, which leads to ease of setting permissions by schema.

EDIT for additional question

drop schema test1 

Msg 3729, Level 16, State 1, Line 1
Cannot drop schema 'test1' because it is being referenced by object 'copyme'.

You cannot drop a schema when it is in use. You have to first remove all objects from the schema.

Related reading:

  1. What good are SQL Server schemas?
  2. MSDN: User-Schema Separation
vote vote


Schema is a way of categorising the objects in a database. It can be useful if you have several applications share a single database and while there is some common set of data that all application accesses.

vote vote


Database is like container of data with schema, and schemas is layout of the tables there data types, relations and stuff

vote vote


Schema says what tables are in database, what columns they have and how they are related. Each database has its own schema.

vote vote


Schema in SQL Server is an object that conceptually holds definitions for other database objects such as tables,views,stored procedures etc.

Top 3 video Explaining sql server - Difference between database and schema