CREATE DATABASE
Create a database called "example_db":
CREATE DATABASE example_db;
CREATE TABLE
Create a table called "employees" to store employee information:
CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(50),
age INT,
department VARCHAR(50)
);
ALTER TABLE
Add a new column "salary" to the "employees" table:
ALTER TABLE employees
ADD COLUMN salary DECIMAL(10, 2);
DROP DATABASE
Drop the database named "example_db" and all tables in it:
DROP DATABASE example_db;
DROP TABLE
Drop the table named "employees":
DROP TABLE employees;
TRUNCATE TABLE
Clear all data in the "employees" table, but keep the structure of the table:
TRUNCATE TABLE employees;
RENAME TABLE
Rename the "employees" table to "staff":
RENAME TABLE employees TO staff;
In practical applications, operations on databases and tables need to be done carefully to ensure that you understand the consequences of operations to avoid irreversible data loss. It is strongly recommended to make a backup before deleting!