[sql-server] Difference between database and schema

What's the difference between a Database and a Schema in SQL Server? Both are the containers of tables and data.

If a Schema is deleted, then are all the tables contained in that schema also deleted automatically or are they deleted when the Database is deleted?

This question is related to sql-server database sql-server-2005 database-schema

The answer is


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.


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


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


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


Examples related to sql-server

Passing multiple values for same variable in stored procedure SQL permissions for roles Count the Number of Tables in a SQL Server Database Visual Studio 2017 does not have Business Intelligence Integration Services/Projects ALTER TABLE DROP COLUMN failed because one or more objects access this column Create Local SQL Server database How to create temp table using Create statement in SQL Server? SQL Query Where Date = Today Minus 7 Days How do I pass a list as a parameter in a stored procedure? SQL Server date format yyyymmdd

Examples related to database

Implement specialization in ER diagram phpMyAdmin - Error > Incorrect format parameter? Authentication plugin 'caching_sha2_password' cannot be loaded Room - Schema export directory is not provided to the annotation processor so we cannot export the schema SQL Query Where Date = Today Minus 7 Days MySQL Error: : 'Access denied for user 'root'@'localhost' SQL Server date format yyyymmdd How to create a foreign key in phpmyadmin WooCommerce: Finding the products in database TypeError: tuple indices must be integers, not str

Examples related to sql-server-2005

Add a row number to result set of a SQL query SQL Server : Transpose rows to columns Select info from table where row has max date How to query for Xml values and attributes from table in SQL Server? How to restore SQL Server 2014 backup in SQL Server 2008 SQL Server 2005 Using CHARINDEX() To split a string Is it necessary to use # for creating temp tables in SQL server? SQL Query to find the last day of the month JDBC connection to MSSQL server in windows authentication mode How to convert the system date format to dd/mm/yy in SQL Server 2008 R2?

Examples related to database-schema

How can I initialize a MySQL database with schema in a Docker container? What are OLTP and OLAP. What is the difference between them? How to store arrays in MySQL? When to use MyISAM and InnoDB? How to SELECT in Oracle using a DBLINK located in a different schema? How do I set the default schema for a user in MySQL Difference Between Schema / Database in MySQL Differences between key, superkey, minimal superkey, candidate key and primary key How to get all columns' names for all the tables in MySQL? Difference between database and schema