DBMS

DBMS Languages

DBMS Languages

DBMS Languages

Database management system (DBMS) is a software system that enables users to define, create, maintain, and control access to a database. There are several languages used in DBMS to perform various operations. In this blog post, we will discuss the different languages used in DBMS.

DBMS languages are required to practically implement the design of the database. They are of following types:

DDL (Data Definition Language)

DCL (Data Control Language)

DML (Data Manipulation Language)

TCL (Transaction Control Language)

 

DDL (Data Definition Language)

It is used to define database structure or skeleton of the database. It is used to create schema, tables, indexes, constraints, etc. in the database.

DDL is used to store and  access the information of metadata like the number of tables and schemas, their names, indexes, columns in each table, constraints, etc.

Some of the tasks of DDL are: 

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.

Rename: 

It is used to rename an object.

Comment: 

It is used to comment on the data dictionary.

 

DML (Data Manipulation Language)

It is used for accessing and manipulating data in a database.  It handles user requests.

Some of the tasks of DML are: 

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.

Call: 

It is used to call a structured query language.

 

DCL (Data Control Language)

It is used to give and take away authorizations and privileges to users or user groups 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.)
 

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.
Following operations have the authorization of Revoke:
 
CONNECT, INSERT, EXECUTE, DELETE, UPDATE and SELECT.
 
 

TCL (Transaction Control Language)

 
TCL is used to run the changes made by the DML statement. TCL can be grouped into a logical transaction.

Some tasks that come under TCL are:

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.

Here are some examples of languages used in DBMS:

  1. SQL (Structured Query Language): SQL is the most widely used language for managing relational databases. It is used to create, modify, and query databases. Here’s an example of a SQL query:

SELECT * FROM customers WHERE country=’USA’;

  1. PL/SQL (Procedural Language/Structured Query Language): PL/SQL is an extension of SQL that adds procedural programming features to SQL. It is used to create stored procedures, functions, and triggers. Here’s an example of a PL/SQL block:

DECLARE x NUMBER := 10; BEGIN IF x > 5 THEN DBMS_OUTPUT.PUT_LINE(‘x is greater than 5’); ELSE DBMS_OUTPUT.PUT_LINE(‘x is less than or equal to 5’); END IF; END;

  1. T-SQL (Transact-SQL): T-SQL is a dialect of SQL that is used by Microsoft SQL Server. It includes additional features like transaction management, error handling, and cursors. Here’s an example of a T-SQL query:

SELECT FirstName, LastName, OrderDate FROM Customers JOIN Orders ON Customers.CustomerID = Orders.CustomerID WHERE OrderDate BETWEEN ’01/01/2022′ AND ’12/31/2022′;

  1. PL/pgSQL (Procedural Language/PostgreSQL): PL/pgSQL is a procedural language used by PostgreSQL. It is similar to PL/SQL and includes features like loops, conditionals, and exception handling. Here’s an example of a PL/pgSQL function:

CREATE FUNCTION get_total_price(order_id INT) RETURNS NUMERIC AS $$ DECLARE total_price NUMERIC := 0; BEGIN SELECT SUM(quantity*price) INTO total_price FROM order_items WHERE order_id = $1; RETURN total_price; END;

5. MongoDB Query Language: MongoDB is a NoSQL database that uses its own query language. It is used to create, modify, and retrieve documents in a MongoDB database. Here’s an example of a MongoDB query: db.users.find({ “age”: { “$gt”: 18 } }).limit(10); These are just a few examples of the many languages used in DBMS. Each language has its own syntax and features, and is used in different contexts depending on the specific needs of the database and application.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button