PostgreSQL DROP TABLE
The DROP TABLE Statement
The DROP TABLE
statement is used to drop an existing table in a database.
Note: Be careful before dropping a table. Deleting a table will result in loss of all information stored in the table!
The following SQL statement drops the existing table cars
:
Example
Delete the cars
table:
DROP TABLE cars;
Result
DROP TABLE
Display Table
To check the result we can display the table with this SQL statement:
Example
SELECT * FROM cars;
Which will result in an error, because the cars
table no longer exists:
Result
ERROR: relation "cars" does not exist
LINE 1: SELECT * FROM cars;
^
Exercise?What is this?
Test your skills by answering a few questions about the topics of this page
Drag and drop the missing code to delete the table named 'flowers'.
flowers;
ALTER
TABLE
DROP
DELETE
REMOVE
FROM
TRUNCATE