Using SQL: Part 3: DROP TABLE

Learning SQL

Using SQL

Structured Query Language (SQL) is a declarative programming language used for accessing data storied in relational databases. It appears in or is a core part of many common software packages like MySQL, PostgreSQL, Microsoft SQL Server, and Oracle Database.


While the standard actions of SELECT, INSERT, UPDATE, and DELETE help with interacting with existing data, there are also ways to add, change, or remove tables themselves. These are CREATE TABLE, ALTER TABLE, and DROP TABLE.

DROP TABLE

As with the use of the DROP keyword with ALTER TABLE to change columns, it can also be used remove tables themselves.

Table Name: Companies
IDName
Table Name: People
IDName
1Dan
2Chad

Like with all other keywords when working with tables, the name of the table following the keywords.

DROP TABLE Companies
Table Name: People
IDName
1Dan
2Chad

TRUNCATE TABLE

When run, the DROP TABLE keywords simply delete and remove the table. Sometimes, deleting the data but not removing the table itself can be more useful. For that, the keywords TRUNCATE TABLE can be used.

TRUNCATE TABLE People
Table Name: People
IDName