PostgreSQL Tutorial
Advanced PostgreSQL
PostgreSQL Interfaces
PostgreSQL Useful Resources
Selected Reading
- PostgreSQL - Distinct Keyword
- PostgreSQL - Having Clause
- PostgreSQL - With Clause
- PostgreSQL - Group By
- PostgreSQL - Order By Clause
- PostgreSQL - Limit Clause
- PostgreSQL - Like Clause
- PostgreSQL - Delete Query
- PostgreSQL - Update Query
- PostgreSQL - AND & OR Clauses
- PostgreSQL - Where Clause
- PostgreSQL - Expressions
- PostgreSQL - Operators
- PostgreSQL - Select Query
- PostgreSQL - Insert Query
- PostgreSQL - Schema
- PostgreSQL - Drop Table
- PostgreSQL - Create Table
- PostgreSQL - Drop Database
- PostgreSQL - Select Database
- PostgreSQL - Create Database
- PostgreSQL - Data Types
- PostgreSQL - Syntax
- PostgreSQL - Environment Setup
- PostgreSQL - Overview
- PostgreSQL - Home
Advanced PostgreSQL
- PostgreSQL - Useful Functions
- PostgreSQL - Functions
- Date/Time Functions & Operators
- PostgreSQL - Privileges
- PostgreSQL - Auto Increment
- PostgreSQL - Sub Queries
- PostgreSQL - Locks
- PostgreSQL - Transactions
- PostgreSQL - Views
- Truncate Table Command
- PostgreSQL - Alter Table Command
- PostgreSQL - Indexes
- PostgreSQL - Triggers
- PostgreSQL - Alias Syntax
- PostgreSQL - NULL Values
- PostgreSQL - Unions Clause
- PostgreSQL - Joins
- PostgreSQL - Constraints
PostgreSQL Interfaces
PostgreSQL Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
PostgreSQL - Drop Table
PostgreSQL - DROP Table
The PostgreSQL DROP TABLE statement is used to remove a table definition and all associated data, indexes, rules, triggers, and constraints for that table.
You have to be careful while using this command because once a table is deleted then all the information available in the table would also be lost forever.
Syntax
Basic syntax of DROP TABLE statement is as follows −
DROP TABLE table_name;
Example
We had created the tables DEPARTMENT and COMPANY in the previous chapter. First, verify these tables (use d to pst the tables) −
testdb-# d
This would produce the following result −
List of relations Schema | Name | Type | Owner --------+------------+-------+---------- pubpc | company | table | postgres pubpc | department | table | postgres (2 rows)
This means DEPARTMENT and COMPANY tables are present. So let us drop them as follows −
testdb=# drop table department, company;
This would produce the following result −
DROP TABLE testdb=# d relations found. testdb=#
The message returned DROP TABLE indicates that drop command is executed successfully.
Advertisements