- Data Definition Language (DDL):
- What it does: Defines and manages the structure of the database.
- Common commands: Create (make something new), Drop (get rid of something), Alter (change something), Truncate (remove all data from a table).
- Who uses it: Database administrators, designers, and developers.
- Example: Creating a new table, changing the datatype of a column.
- Data Manipulation Language (DML):
- What it does: Deals with the data within the database.
- Types:
- Procedural DML: Specifies how to get the data.
- Declarative DML (Non-procedural): Specifies what data is needed without detailing how to get it.
- Common commands: Insert (add new data), Update (modify existing data), Delete (remove data), Query (retrieve data).
- Who uses it: Application developers and end-users.
- Example: Adding a new record, updating a customer’s information.
- Data Control Language (DCL):
- What it does: Controls access to data and the database.
- Common commands: Commit (save changes), Rollback (undo changes).
- Who uses it: Database administrators.
- Example: Confirming and saving changes, canceling and reverting changes.
- Data Query Language (DQL):
- What it does: Retrieves and organizes data from the database.
- Common commands: Select (retrieve data).
- Who uses it: Application developers and end-users.
- Example: Fetching a list of products from a database.
- View Definition Language (VDL):
- What it does: Specifies user views and their mapping to the conceptual schema.
- Features: Creates virtual tables for users, defines what records are available to different user classes, specifies user interfaces.
- Example: Defining a view that shows only specific columns of a table.
Now, as for SQL, it is primarily a Data Manipulation Language (DML). It is used for querying, updating, and managing data within the database. So, when you write SQL queries, you are using a language that falls under the category of DML.