Module 3 - Data Manipulation Language - Part 1 INSTER
2026-02-08 11:14
Tags: #ADV_DBMS
Author: Duke Hsu
Module 3 - Data Manipulation Language - Part 1 INSTER
Module Intended Learning Outcome
- Make use of
INSERT,UPDATE, andDELETEinstructions for the data - Construct single queries using SQL
SELECTcommand
Concept
SQL Data Manipulation Language (DML)
- SELECT: Used to select data from the table (show data).
- UPDATE: Used to update existing data with a condition (modify data).
- INSERT INTO: Used to insert new data into the table (insert data).
- DELETE: Used to delete data from the table with a condition (delete data).
- DML statement is executed when you :
- Add new rows to a table
- Modify existing rows in a table
- Remove existing rows from a table
- note: 所有操作都是針對rows的
INSERT Statement Syntax
The INSERT INTO statement is used to insert new records in a table
Specify column insert and for all the columns of the table.
Syntax:
1 2 3 4 5 6 7 8 | |
Example:
1 2 3 4 5 6 7 8 | |
Copy all columns from one table to another table
Syntax:
1 2 3 | |
Example:
1 2 3 | |
Insert Multiple Rows
To insert multiple rows of data, we use the same INSERT INTO statement, but with multiple values:
Example
1 2 3 4 5 | |
Note
Make sure you separate each set of values with a comma , .
The SQL UPDATE Statement
The UPDATE statement is used to modify the existing records in a table.
Syntax:
1 2 3 | |
Example:
1 2 3 | |
Warning
The WHERE clause specifies which records that should be updated , if you omit the WHERE clause, all records in the table will be updated !!
The SQL DELETE Statement
The DELETE statement is used to delete existing records in a table
Delete with condition
The DELETE clause specifies which records that should be updated , if you omit the DELETE clause, all records in the table will be deleted!!
Syntax:
1 2 | |
Example:
1 2 | |
Delete with out condition
It is possible to delete all rows in a table without deleting the table This means that the table structure, attributes, and indexes will be intact;
Syntax:
1 | |
Example:
1 | |
Summary
- The
INSERT INTOstatement is used to insert new records in a table. - The
UPDATEstatement is used to modify the existing records in a table - The
DELETEstatement is used to delete existing records in a table.
References:
ADMBS_MODULE-3.PPTX