TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    MySQL

    MySQL DROP TABLE Statement

    Overview

    In this tutorial, we will learn MySQL DROP TABLE statement with examples. The DROP TABLE removes one or more tables. All the table data and the table definition will be removed.

    A DROP TABLE statement cannot be undone. This is a destructive statement, so be careful and use caution when executing this statement.

    Syntax

    The general syntax for the statement is as follows:

    mysql> DROP [TEMPORARY] TABLE [IF EXISTS] <database_table_name>

    We can also use the DROP statement to drop multiple database tables. We must have the DROP privilege for dropping each table.

    mysql> DROP [TEMPORARY] TABLE [IF EXISTS] <table_name1> [{, <table_name2>}…]

     

    The TEMPORARY keyword drops only the TEMPORARY tables. A TEMPORARY table is visible only to the client that created it. TEMPORARY keyword is a good way  to ensure that we do not accidentally drop a non-TEMPORARY table.

    Use IF EXISTS to prevent an error from occurring for tables that do not exist in the database. A NOTE message is generated for each non-existent table when using the IF EXISTS clause in the statement.

    Examples

    Let’s drop a table R_Actor from the database.

    mysql> DROP TABLE IF EXISTS R_Actor;
    Query OK, 0 rows affected (0.10 sec)

    A successful DROP statement returns Query OK message. We can verify using the SHOW TABLES command. The table should be deleted from the list.

    Warnings non-existent table

    mysql> DROP TABLE IF EXISTS non_existent_table;
    Query OK, 0 rows affected, 1 warning (0.00 sec)

    mysql> SHOW WARNINGS;
    +——-+——+——————————————-+
    | Level | Code | Message |
    +——-+——+——————————————-+
    | Note | 1051 | Unknown table ‘sakila.non_existent_table’ |
    +——-+——+——————————————-+
    1 row in set (0.00 sec)

    mysql>

    DROP TABLE Statement Warnings

    —

    MySQL Tutorials

    MySQL Tutorials on this website:

    https://www.testingdocs.com/mysql-tutorials-for-beginners/

    For more information on MySQL Database:

    https://www.mysql.com/

    Related Posts

    Stellar Converter for Database Tool

    MySQL /

    Stellar Converter for Database

    Stellar MySQL Log Analyzer

    MySQL /

    Stellar Log Analyzer for MySQL

    Stellar Repair for MySQL

    MySQL /

    Stellar Repair for MySQL

    MySQL /

    How to secure your SQL Database: Tips and Tricks

    Stellar Converter for Database

    MySQL /

    Database Converter Tools

    ‹ MySQL CREATE TEMPORARY TABLE Statement› MySQL Import using SQL file

    Recent Posts

    • Running Tests in Parallel with Selenium Grid
    • Advanced Selenium Features
    • Locating Web Elements
    • Running the Test Script
    • Writing Your First Selenium Test Script
    • Getting Started with Selenium Automation Testing
    • Setting Up the Environment
    • How can you monitor the Quality Assurance Audit?
    • Leveraging LambdaTest with Appium 2.0
    • Appium 2.0 Plugins ListAppium 2.0 Plugins
    • Touch Actions and Multi-Touch Actions
    • Changes in Drivers and Classes
    • Appium Inspector
    • Capabilities in Appium 2.0
    • Appium 2.0 Driver ListAppium 2.0 Driver Installation & Management
    CyberLink Multimedia Software

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com