title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | f1_keywords | helpviewer_keywords | dev_langs | monikerRange | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DROP SCHEMA (Transact-SQL) |
DROP SCHEMA (Transact-SQL) |
WilliamDAssafMSFT |
wiassaf |
05/11/2017 |
sql |
t-sql |
reference |
|
|
|
>=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current||=fabric |
[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw]
Removes a schema from the database.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
-- Syntax for SQL Server and Azure SQL Database
DROP SCHEMA [ IF EXISTS ] schema_name
-- Syntax for Azure Synapse Analytics and Parallel Data Warehouse
DROP SCHEMA schema_name
IF EXISTS
Applies to: [!INCLUDEssNoVersion] ( [!INCLUDEsssql16-md] through current version).
Conditionally drops the schema only if it already exists.
schema_name
Is the name by which the schema is known within the database.
The schema that is being dropped must not contain any objects. If the schema contains objects, the DROP statement fails.
Information about schemas is visible in the sys.schemas catalog view.
Caution [!INCLUDEssCautionUserSchema]
Requires CONTROL permission on the schema or ALTER ANY SCHEMA permission on the database.
The following example starts with a single CREATE SCHEMA
statement. The statement creates the schema Sprockets
that is owned by Krishna
and a table Sprockets.NineProngs
, and then grants SELECT
permission to Anibal
and denies SELECT
permission to Hung-Fu
.
CREATE SCHEMA Sprockets AUTHORIZATION Krishna
CREATE TABLE NineProngs (source INT, cost INT, partnumber INT)
GRANT SELECT TO Anibal
DENY SELECT TO [Hung-Fu];
GO
The following statements drop the schema. Note that you must first drop the table that is contained by the schema.
DROP TABLE Sprockets.NineProngs;
DROP SCHEMA Sprockets;
GO
CREATE SCHEMA (Transact-SQL)
ALTER SCHEMA (Transact-SQL)
DROP SCHEMA (Transact-SQL)
EVENTDATA (Transact-SQL)