Website logo
⌘K
🏠Homepage
👋Introduction
Key Concepts & Architecture
🚀Run Oxla in 2 minutes
🏃‍♂️Run Oxla on S3
🛫Multi-node Deployment
👨‍💻SQL Reference
SQL Queries
SQL Clauses
SQL Data Types
SQL Functions
Schema
Comment Support
⛓️SQL Mutations
DELETE
UPDATE
🚨Error Handling
🆚Differences Between Oxla vs. PostgreSQL
🔄Understanding Transactions
📈Public Metrics
⚙️Oxla Configuration File
✨Changelog
Docs powered by Archbee
SQL Reference
SQL Queries

DROP statement

7min

Overview

In this section, we will learn how to delete the data from a table using the DROP query.

⚠️ Watch out! Running a DROP query will also delete all existing records from the table.

Syntax

The basic syntax for the DROP query is as follows:

Syntax
DROP TABLE table_name;


In this syntax, we have several elements that are elaborated on below.

  1. DROP represents the statement name.
  2. TABLE entity type you want to drop.
  3. table_name defines which table you want to remove.

The DROP example below is executed in the public schema. You can also drop a table from another specific schema. Click here for more info.

Example

We have a table named warehouse that stores the product's id, name, and quantity:

Create a table
CREATE TABLE warehouse (
  id int,
  product string,
  qty int
);
INSERT INTO warehouse 
    (id, product, qty) 
VALUES 
    (889771,'Shirt',22),
    (777821,'Hat',99),
    (103829,'Bed Cover',12);

Display the table
 SELECT * FROM warehouse;


It will create a table as shown below:

The warehouse table
+---------+------------+---------+
| id      | product    | qty     | 
+---------+------------+---------+
| 889771  | Shirt      | 22      |
| 777821  | Hat        | 99      |
| 103829  | Bed Cover  | 12      |
+---------+------------+---------+



1) Use the following query to delete the warehouse’s table:

Drop the table
DROP TABLE warehouse;


2) If you have successfully run the query, you will get the following output: the table and the values within it are deleted.

Drop the table
DROP TABLE

Query returned successfully in 284 msec.


😥 If you attempt to use the table for any operation, you will find that the table no longer exists.



Updated 09 Oct 2023
Did this page help you?
PREVIOUS
SELECT statement
NEXT
SHOW TABLES statement
Docs powered by Archbee
TABLE OF CONTENTS
Overview
Syntax
Example
Docs powered by Archbee

©2023 Oxla