DBMS Programs
DBMS Programs
Program:
1 | Page
Result: The above program executed successfully.
2 | Page
DML Commands in SQL
DML is an abbreviation of Data Manipulation Language.
Data Manipulation Language commands in Structured Query Language manipulate
the data in the database. DML commands are used to retrieve records, add records,
update the records, as well as remove the data from the existing table.
2,Aim: Create a DML commands in SQL language.
Example 2: This example fetches all the data of the selected column from the
table:
SELECT STUD_ID, STUD_NAME, STUD_AGE FROM STUD;
The above query retrieves records from the selected columns
The output of the above query is as follows:
STUD_ID STUD_NAME STUD_AGE
1 Shivani Agrawal 15
2 Pranoti Shende 16
3 Vaibhav Sharma 15
4 | Page
Example 3: These examples fetch a single row of all data using the WHERE
clause specified by column name from the table:
SELECT * FROM STUD WHERE STUD_ID = 1;
The above query retrieves records of student information whose student id is 1.
The output of the above query is as follows:
STUD_ID STUD_NAME STUD_AGE STUD_CITY STUD_MARKS
5 | Page
2 Pranoti Shende 16 Kolhapur 95
I want to modify the student city whose student id is 3. To update records, we will
execute the following Data Manipulation Language UPDATE command:
UPDATE STUD SET STUD_CITY = ‘PUNE’ WHERE STUD_ID = 3;
We will execute the SELECT query to verify whether the student information is
successfully updated or not
UPDATE STUD SET STUD_CITY = ‘PUNE’ WHERE STUD_ID = 3;
The output of the above query is as follows:
STUD_ID STUD_NAME STUD_AGE STUD_CITY STUD_MARKS
Example 2: The below example describes how to modify the multiple values.
We need to modify the student marks and student age whose student city is ‘Pune’.
To update records, we will execute the following Data Manipulation Language
UPDATE command:
UPDATE STUD SET STUD_MARKS = 93, STUD_AGE = 16 WHERE
STUD_CITY = 'PUNE';
We will execute the SELECT query to verify whether the student information is
successfully updated or not
SELECT * FROM STUD WHERE STUD_CITY = ‘PUNE’;
The output of the above query is as follows:
STUD_ID STUD_NAME STUD_AGE STUD_CITY STUD_MARKS
6 | Page
4. DELETE DML Command
The DELETE command is a DML command that removes the data from the
existing table. The WHERE clause conditions are used in the queries to remove
data from the table.
The syntax of the DELETE command is as follows:
DELETE FROM TABLE_NAME WHERE CONDITION;
Examples of DELETE Command
Example 1: The below example describes how to remove the records from the
existing table.
Consider the already existing table with the following data
Table Name: Stud
STUD_ID STUD_NAME STUD_AGE STUD_CITY STUD_MARKS
For example, we want to delete the records from the stud table whose city name is
'Mumbai'. To remove records, we will execute the following Data Manipulation
Language DELETE command:
DELETE FROM STUD WHERE STUD_CITY = ‘MUMBAI’;
We will execute the SELECT query to verify whether the student information is
successfully deleted or not
SELECT * FROM STUD;
The output of the above query is as follows:
STUD_ID STUD_NAME STUD_AGE STUD_CITY STUD_MARKS
7 | Page
3 Vaibhav Sharma 16 Pune 93
8 | Page