SQL
HTML
CSS
JavaScript
jQuery
PHP
WordPress
SQL Reference

Quick Reference

The DROP keyword is used to delete existing columns, constraints, databases, indexes, tables, and views.

DROP DATABASE

The following deletes a database called “sitename_db”.

				
					DROP DATABASE sitename_db;
				
			

DROP TABLE

The following deletes the table Customers.

				
					DROP TABLE Customers;
				
			

DROP COLUMN

The following deletes the county secondary_email column from the Customers table.

				
					ALTER TABLE Customers
DROP COLUMN secondary_email;
				
			

DROP a UNIQUE CONSTRAINT

The following deletes the unique constraint named uc_customer_names from the Customers table.

MySQL:

				
					ALTER TABLE Customers
DROP INDEX uc_customer_names;
				
			

SQL Server:

				
					ALTER TABLE Customers
DROP CONSTRAINT uc_customer_names;
				
			

DROP a PRIMARY KEY CONSTRAINT

The following deletes the primary key constraint named pk_customer_names from the Customers table.

MySQL:

				
					ALTER TABLE Customers
DROP PRIMARY KEY;
				
			

SQL Server:

				
					ALTER TABLE Customers
DROP CONSTRAINT pk_customer_names;
				
			

DROP a FOREIGN KEY CONSTRAINT

The following deletes the foreign key constraint named fk_customer_names from the Customers table.

MySQL:

				
					ALTER TABLE Customers
DROP FOREIGN KEY fk_customer_names;
				
			

SQL Server:

				
					ALTER TABLE Customers
DROP CONSTRAINT fk_customer_names;
				
			

DROP a CHECK CONSTRAINT

The following deletes the check constraint named chk_age from the Persons table.

MySQL:

				
					ALTER TABLE Persons
DROP CHECK chk_age;
				
			

SQL Server:

				
					ALTER TABLE Persons
DROP CONSTRAINT chk_age;
				
			

DROP DEFAULT

The following deletes the default country value requirement from the Customers table.

MySQL:

				
					ALTER TABLE Customers
ALTER country DROP DEFAULT;
				
			

SQL Server:

				
					ALTER TABLE Customers
ALTER COLUMN country DROP DEFAULT;
				
			

DROP INDEX

The following deletes an index named “idx_customer” from the Customers table.

MySQL:

				
					ALTER TABLE Customers
DROP INDEX idx_customer;
				
			

SQL Server:

				
					DROP INDEX Customers.idx_customer;
				
			

DROP VIEW

The following drops a view called “Canada Customers”.

				
					DROP VIEW [Canadian Customers]';
				
			

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

SQL
HTML
CSS
JavaScript
jQuery
PHP
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.