We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4
TYPES OF DB LANGUAGE
The different types of database languages used in Relational Database
Management Systems (RDBMS), with examples specifically related to MySQL:
DDL (Data Definition Language):
DDL is used to define the database’s internal structure and schema. It includes commands for creating tables, indexes, constraints, and other database objects. Examples of DDL commands in MySQL:
Create Table: CREATE TABLE Students ( student_id INT PRIMARY KEY, student_name VARCHAR(50), age INT );
Alter Table (to add a new column):
ALTER TABLE Students ADD weight DECIMAL(5,2);
Drop Table (to delete a table):
DROP TABLE Students;
DML (Data Manipulation Language):
DML is used to manipulate data within the database. It includes commands for inserting, updating, and deleting records. Examples of DML commands in MySQL:
Insert (to add data):
INSERT INTO Students (student_id, student_name, age) VALUES (1, 'Alice', 20);
Update (to modify existing data):
UPDATE Students SET age = 21 WHERE student_id = 1;
Delete (to remove records):
DELETE FROM Students WHERE student_id = 1;
DCL (Data Control Language):
DCL is used to control access and permissions to the database. It includes commands for granting or revoking privileges. Examples of DCL commands in MySQL:
Grant (to give permissions):
GRANT SELECT, INSERT ON Students TO 'user1'@'localhost';
Revoke (to remove permissions):
REVOKE DELETE ON Students FROM 'user1'@'localhost';
TCL (Transaction Control Language):
TCL is used to manage transactions within the database. It includes commands for committing or rolling back changes. Examples of TCL commands in MySQL:
Commit (to save changes):
COMMIT;
Rollback (to undo changes):
ROLLBACK;
1. Data Definition Language (DDL)
DDL stands for Data Definition Language. It is used to define database structure or pattern. It is used to create schema, tables, indexes, constraints, etc. in the database. Using the DDL statements, you can create the skeleton of the database. Data definition language is used to store the information of metadata like the number of tables and schemas, their names, indexes, columns in each table, constraints, etc. Here are some tasks that come under DDL: Create: It is used to create objects in the database. Alter: It is used to alter the structure of the database. Drop: It is used to delete objects from the database. Truncate: It is used to remove all records from a table. Rename: It is used to rename an object. Comment: It is used to comment on the data dictionary. Data Manipulation Language (DML) DML stands for Data Manipulation Language. It is used for accessing and manipulating data in a database. It handles user requests. Here are some tasks that come under DML: These commands are used to update the database schema that's why they come under Data definition language. Select: It is used to retrieve data from a database. Insert: It is used to insert data into a table. Update: It is used to update existing data within a table. Delete: It is used to delete all records from a table. Merge: It performs UPSERT operation, i.e., insert or update operations. Call: It is used to call a structured query language or a Java subprogram. Explain Plan: It has the parameter of explaining data. Lock Table: It controls concurrency. 3. Data Control Language (DCL) DCL stands for Data Control Language. It is used to retrieve the stored or saved data. The DCL execution is transactional. It also has rollback parameters. (But in Oracle database, the execution of data control language does not have the feature of rolling back.) Here are some tasks that come under DCL: Grant: It is used to give user access privileges to a database. Revoke: It is used to take back permissions from the user. There are the following operations which have the authorization of Revoke: CONNECT, INSERT, USAGE, EXECUTE, DELETE, UPDATE and SELECT. 4. Transaction Control Language (TCL) TCL is used to run the changes made by the DML statement. TCL can be grouped into a logical transaction. Here are some tasks that come under TCL: Commit: It is used to save the transaction on the database. Rollback: It is used to restore the database to original since the last Commit.