beginnersbook.com

  • Home
  • All Tutorials
    • Learn Servlet
    • Learn JSP
    • Learn JSTL
    • Learn C
    • Learn C++
    • Learn MongoDB
    • Learn XML
    • Learn Python
    • Learn Perl
    • Learn Kotlin
    • Learn jQuery
  • Core Java
  • OOPs
  • Collections
  • Java I/O
  • JSON
  • DBMS

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 Introduction
  • SQL Syntax
  • 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

Recently Added..

  • JSON Tutorial
  • Java Regular Expressions Tutorial
  • Java Enum Tutorial
  • Java Annotations Tutorial

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap