BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

SQL – DROP Table Statement to delete the entire table

By Chaitanya Singh | Filed Under: SQL

The DROP TABLE statement is used for deleting an entire table. This statement deletes the table definition, data, constraints and all the info that is associated or stored in table.

Syntax:

DROP TABLE TableName;

For e.g.
Lets say we have a table named “EMPLOYEES”. This is how we can see the table definition.

SQL> DESC EMPLOYEES;
+---------+---------------+------+-----+---------+
| Field   | Type          | Null | Key | Default |
+---------+---------------+------+-----+---------+
| SSN     | CHAR(10)      | NO   | PRI |         |      
| EMP-NAME| varchar(35)   | NO   |     |         |       
| EMP_AGE | int(11)       | NO   |     |         |      
| EMP_ADDR| varchar(45)   | YES  |     | NULL    |     
+---------+---------------+------+-----+---------+
4 rows in set (0.00 sec)

Lets delete the table.

SQL> DROP TABLE EMPLOYEES;
Query OK, 0 rows affected (0.01 sec)

Lets verify whether the table dropped successfully.

SQL> DESC EMPLOYEES;
ERROR: Table 'DB1.EMPLOYEES' doesn't exist

As you can see that table has been successfully deleted from the database “DB1”.

Comments

  1. Kalimuthu says

    June 6, 2016 at 11:25 AM

    If we have created new table i,e., Associates from an old table i.e., Employee, when we delete the parent table Employee, will it have any impact in the table Associates?

    Please help to understand.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

SQL Tutorial

  • SQL Tutorial
  • SQL Introduction
  • SQL Syntax
  • SQL Data Types

SQL Database

  • SQL CREATE DB
  • SQL DROP DB
  • SQL Rename DB
  • SQL USE DB

SQL Queries

  • SQL Select
  • SQL Select Distinct
  • SQL Select Count
  • SQL Select Top
  • SQL Where
  • SQL AND, OR & NOT
  • SQL Order By
  • SQL Insert Into
  • SQL Insert Into SELECT
  • SQL Select Random
  • SQL Alias
  • SQL NULL Check
  • SQL Update
  • SQL Delete
  • SQL MIN, MAX
  • SQL SUM
  • SQL AVG

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap