- Tags: Keyword, MySQL, SQL Server
- Categories: Reference, SQL Keywords, SQL Reference
Quick Reference
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.
Why 1SMARTchicken?
See More →
Thanks for your support!
SQL Books
All are affiliate links. Thank you for your support!
SQL NOTES:
- Any work being done to modify the structure of a database or delete tables or the the database itself should only be done after making a recent backup
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.