Data Definition Language (DDL):
Common DDL Commands:
CREATE: Generates new database objects like tables, indexes, views, or stored procedures. Defines object attributes such as columns, data types, constraints, and properties.ALTER: Modifies the structure of existing database objects. Enables column addition/removal, data type alterations, and constraint modifications.
DROP: Removes a database object like a table, index, view, or stored procedure permanently from the database.
Data Manipulation Language (DML):
Key DML Commands:
- SELECT: Retrieves data from one or multiple tables based on specified conditions. Allows column selection, filtering via WHERE clause, result sorting with ORDER BY, aggregate functions (e.g., SUM, AVG), and table joins.
- INSERT: Adds new records into a table with specified values or selections from other tables via sub-queries, thereby populating the database with fresh data.
- UPDATE: Modifies existing records within a table based on specified conditions, allowing alterations to specific columns.
- DELETE: Removes records from a table based on defined criteria, permanently deleting specified rows.
Transaction Control Language (TCL):
Common TCL Commands:
- COMMIT: Permanently saves changes made within a transaction to the database.
- ROLLBACK: Reverts changes made within a transaction, restoring the database to its previous state.
- SAVEPOINT: Sets a savepoint within a transaction, enabling partial rollback to a specific point.
Data Control Language (DCL):
Key DCL Commands:
- GRANT: Bestows specific privileges on users or roles, permitting designated operations on database objects.
- REVOKE: Withdraws previously granted privileges from users or roles, limiting access to specific database objects.
Data Query Language (DQL):
DQL commands center around extracting specific data from a database using the SELECT statement.
Key DQL Commands:
SELECT: Retrieves data from one or multiple tables based on specified conditions. It allows for various functionalities such as choosing specific columns, filtering data using the WHERE clause, sorting results using ORDER BY, performing aggregate functions like SUM or AVG, and conducting table joins to retrieve data from related tables.
Understanding and utilizing these categories of SQL commands are fundamental in effectively managing databases, structuring data, controlling transactions, and maintaining data security and integrity within a database environment.
0 Comments