T-SQL Tutorial

T-SQL DROP


This article describes how to delete objects in a database.
The DROP statement is part of DDL(Data Definition Language) statements.
Uses DROP statement to delete objects like: database, table, view, trigger, procedure, index, role.



DROP DATABASE

The T-SQL statement DROP DATABASE is used to delete a SQL Server database.

DROP DATABASE database_name;

DROP SCHEMA

The T-SQL statement DROP SCHEMA is used to delete a schema in SQL Server.

DROP SCHEMA schema_name;

DROP TABLE

The T-SQL statement DROP TABLE is used to delete a table in the current database.

DROP TABLE table_name;

DROP COLUMN

The T-SQL statement DROP COLUMN is used to delete a column table.

ALTER TABLE table_name
DROP COLUMN column_name;


DROP VIEW

To delete a view in SQL Server database uses DROP VIEW statement.

DROP VIEW view_name;

DROP TRIGGER

To delete a trigger is used the command DROP TRIGGER.

DROP TRIGGER trigger_name;

DROP PROCEDURE

The T-SQL statement DROP PROCEDURE is used to delete a procedure in a SQL Server database.

DROP PROCEDURE procedure_name;

DROP INDEX

The T-SQL statement DROP INDEX is used to delete a index table.

DROP INDEX table_name.index_name;

DROP ROLE

The T-SQL statement DROP ROLE is used to delete a role in database.

ALTER ROLE role_name
DROP MEMBER user_name;


DROP CONSTRAINT

The DROP CONSTRAINT statement is used to remove a constraint from a table. Constraints are rules or conditions applied to columns in a table to maintain the integrity and accuracy of the data.

ALTER TABLE table_name
DROP CONSTRAINT constraint_name;