1.
Data Definition Language (DDL)
Defines and manages the structure of database objects.
Examples: CREATE, ALTER, DROP, TRUNCATE, RENAME, COMMENT
Purpose: Create or modify tables, indexes, views, and other schema objects.
2. Data Manipulation Language (DML)
Handles the manipulation of data within existing tables.
Examples: SELECT, INSERT, UPDATE, DELETE, MERGE
Purpose: Query, add, modify, or remove data in tables.
3. Data Control Language (DCL)
Manages permissions and access controls for users.
Examples: GRANT, REVOKE
Purpose: Assign or remove privileges to users or roles.
4. Transaction Control Language (TCL)
Controls the processing of transactions in the database.
Examples: COMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTION
Purpose: Manage changes made by DML statements, ensuring data integrity. for
all the functions in the above give brief description of what they do.
Here is a brief description of the main Oracle SQL statement types and their key
functions:
1. Data Definition Language (DDL)
CREATE: Used to create new database objects such as tables, views, indexes, or
functions. For example, CREATE TABLE creates a new table, and CREATE FUNCTION
creates a new function in the database.
ALTER: Modifies the structure of an existing database object. For example, ALTER
TABLE can add, remove, or modify columns in a table, or change constraints.
DROP: Deletes an existing database object, such as a table, view, or function, from
the database permanently.
TRUNCATE: Removes all rows from a table or cluster, but keeps the table structure
for future use. This operation is faster than DELETE and cannot be rolled back.
RENAME: Changes the name of a database object, such as a table or view. All
associated constraints, indexes, and grants are transferred to the new name.
COMMENT: Adds or modifies a comment associated with a database object, which
is stored in the data dictionary for documentation purposes.
2. Data Manipulation Language (DML)
SELECT: Retrieves data from one or more tables or views. It is the primary query
statement in SQL.
INSERT: Adds new rows of data into a table. You specify the table and the values
for each column.
UPDATE: Modifies existing data in a table. You can update one or more columns for
rows that meet a specified condition.
DELETE: Removes existing rows from a table based on a specified condition.
MERGE: Performs insert, update, or delete operations in a single statement,
typically used to synchronize two tables (also known as "upsert").
3. Data Control Language (DCL)
GRANT: Gives specific privileges to users or roles, such as the ability to select,
insert, update, or delete data in a table.
REVOKE: Removes previously granted privileges from users or roles, restricting
their access to database objects.
4. Transaction Control Language (TCL)
COMMIT: Saves all changes made in the current transaction permanently to the
database.
ROLLBACK: Undoes changes made in the current transaction, reverting the
database to the last committed state.
SAVEPOINT: Sets a point within a transaction to which you can later roll back,
allowing partial rollback of a transaction.
SET TRANSACTION: Specifies characteristics for the current transaction, such as
isolation level.