0% found this document useful (0 votes)
82 views11 pages

Database Management System 1: Data Manipulation Language

This document discusses data manipulation language (DML) statements in SQL. It describes how to insert new rows using INSERT, update existing rows using UPDATE, and delete rows using DELETE. INSERT adds values to tables, UPDATE modifies values in tables, and DELETE removes rows from tables. All DML statements can include conditions to target specific rows for the operation.
Copyright
© © All Rights Reserved
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
0% found this document useful (0 votes)
82 views11 pages

Database Management System 1: Data Manipulation Language

This document discusses data manipulation language (DML) statements in SQL. It describes how to insert new rows using INSERT, update existing rows using UPDATE, and delete rows using DELETE. INSERT adds values to tables, UPDATE modifies values in tables, and DELETE removes rows from tables. All DML statements can include conditions to target specific rows for the operation.
Copyright
© © All Rights Reserved
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/ 11

Database Management System 1

Data Manipulation Language


Lesson Objective
After completing this lesson, the student should be
able to:
 Insert new values in the table using the
INSERT statement.
 Modify existing values in the table using the
UPDATE statement
 Delete existing row using DELETE statement.
Data Manipulation Language
 A DML statement is executed when you:
 Add new rows to a table using INSERT statement
 Modify existing rows in a table using UPDATE
statement
 Remove existing rows from a table using DELETE
statement
What is a transaction
A transaction is consists of a collection of Data
Manipulation Language (DML) statements that
form a logical unit of work.
INSERT statement
 Insert a new row containing values for each column.
 List values in the default order of the columns in the
table.
 Optionally, list the columns in the INSERT clause.
 Enclose character and date values within single quotation
marks.
 Add new rows to a table by using the INSERT statement:
INSERT statement cont.
 Syntax:
INSERT INTO tbl_name values (column_list);
 In the syntax:
o TBL_NAME - Is the name of the table
o COLUMN_LIST - Is the name of the column in the table to populate
o VALUES - Is the corresponding value for the column
 Example:
INSERT INTO STUDENTS VALUES
(500,'REYES','ANNA','BSIS','1');
Inserting Rows with Null Values
1. Implicit method: Omit the column from the column list.
 Example:
INSERT INTO STUDENTS
(USN_ID,LASTNAME)
VALUES (502,'CUBAO');
2. Explicit method: Specify the NULL keyword in the VALUES clause.
 EXAMPLE:
INSERT INTO STUDENTS VALUES
(505,'ABIOG','SHIELA',NULL,NULL);
Changing Data in a Table
 Modify existing values in a table with the UPDATE statement:

 Syntax:

UPDATE TBL_NAME
SET COLUMN = NEW VALUES
[WHERE CONDITION];
 In the syntax:
 Tbl_name - Is the name of the table
 set column - Is the name of the column in the table to populate
– new_value - Is the corresponding value or subquery for the column
– condition - Identifies the rows to be updated, should apply either
Comparison Condition, Logical Condition or apply a subquery.
Changing Data in a Table cont.
 Example: 1 column
UPDATE STUDENTS
SET FIRSTNAME = 'MARVIN'
WHERE USN_ID=502;
• Updating two columns in one UPDATE statement.
– To update to or more columns in one UPDATE statement put a comma (,) after
each column called in the SET clause.

 Example:
UPDATE STUDENTS
SET YR_LVL='IRREG', LASTNAME = 'ABIOG'
WHERE USN_ID = 505;
DELETE Statement

 You can remove existing rows from a table by


using the DELETE statement:
 Syntax:
DELETE FROM TBL_NAME
WHERE CONDITION;
 Example:
DELETE FROM STUDENTS
WHERE YR_LVL='1';
Lesson Summary:

In this lesson, you should have learned the


following.

 Insert into to add new rows in a table

 Update to modify existing values is a table

 Delete to remove specific rows in a table

You might also like