SQL DROP TABLE Tutorial
Example Table
We will create a table named employees
to demonstrate the SQL DROP TABLE command:
CREATE TABLE employees (
employee_id INT PRIMARY KEY,
employee_name VARCHAR(100),
hire_date DATE,
salary DECIMAL(10, 2)
);
Creating the Table
To create the table, use the following SQL command:
CREATE TABLE employees (
employee_id INT PRIMARY KEY,
employee_name VARCHAR(100),
hire_date DATE,
salary DECIMAL(10, 2)
);
Result:
Command | CREATE TABLE employees (employee_id INT PRIMARY KEY, employee_name VARCHAR(100), hire_date DATE, salary DECIMAL(10, 2)); |
---|---|
Result |
|
Dropping the Table
To drop the table, use the following SQL command:
DROP TABLE employees;
Result:
Command | DROP TABLE employees; |
---|---|
Result |
|
Important Considerations
Before dropping a table, ensure that:
- You have the necessary permissions to drop the table.
- All important data is backed up, as this operation is irreversible.