SQL Commands Overview
1. SELECT Command:
SELECT * FROM employees WHERE age > 30 ORDER BY name ASC;
- Retrieves all columns from the 'employees' table where the 'age' is greater than 30.
Results are sorted by the 'name' column in ascending order.
2. CREATE DATABASE:
CREATE DATABASE database_name;
- Creates a new database with the specified name.
3. DROP DATABASE:
DROP DATABASE database_name;
- Deletes the specified database.
4. CREATE TABLE:
CREATE TABLE table_name (
column1 datatype constraints,
column2 datatype constraints
);
- Creates a new table with the specified structure.
5. ALTER TABLE:
ALTER TABLE table_name ADD column_name datatype;
- Modifies an existing table, e.g., adds a new column.
6. INSERT Command:
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
- Inserts data into the specified table.
7. UPDATE Command:
UPDATE table_name SET column1 = value1 WHERE condition;
- Updates data in the table based on the condition.
8. DELETE Command:
DELETE FROM table_name WHERE condition;
- Deletes rows from the table based on the condition.
9. CREATE INDEX:
CREATE INDEX index_name ON table_name (column_name);
- Creates an index on the specified column to improve query performance.
10. DROP INDEX:
DROP INDEX index_name;
- Deletes an index from the table.