Data Manipulation Language ( DML ) is the language used to maintain the database in a DMBS. The SQL (Structured Query Language) is the most popular language to manipulate databases.
The DML commands perform following tasks on a database.
The SQL being a DML can do above task without any problem. Other than inserting, deleting or querying database, the SQL has advanced commands to change the schema of relations or create new relations.
It is used for maintaining the database and they are called Data Definition Language (DDL) commands. You can create table, delete a table and do other operations to maintain the structure of your database.
The INSERT command helps insert data into the relation. For example, you can insert values in the ‘MANAGER’ relation as follows.
The schema for Manager relation is given in the previous post about DDL commands.
The SELECT command helps query the database and retrieve the tuples from one or more relations.
There are two types of query – Selection(σ) and Projection(π).
This unary operator selects all the tuple in a relation that meet specific condition using normal conditional operators and logical operator such as AND, OR and NOT.
, will return all the tuples that have an age greater than 30.
This unary operator selects columns, but you can add selection with those retrieved columns.
will return two column – age and salary.
The rename operator will rename the existing field of a relation to a different specified name. Alter is a DDL command that modifies the relation name.
The UPDATE command modifies the value for one or more tuple in the relation. In the following example, we have an updated salary of a manager whose salary is less than 20000.
The result of the update is as follows.
The DELETE will delete the tuple from the relation. Here is an example of DELETE.
The following figure shows the relation Manager after the delete operation. Note that one entry is already deleted successfully.
Ramakrishnan, Johannes Gehrke, and Raghu. 1996. Database Management Systems. McGraw Hill Education; Third edition (1 July 2014).
Wikipedia. n.d. Data definition language. Accessed March 14, 2018. https://en.wikipedia.org/wiki/Data_definition_language.