Lagraoui Mohamed Amine Lab 5

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Lab5:Update&Insert&Delete

1. Target

(1)Master the formats of Insert,Update and Delete.


(2)Master how to write Insert,Update and Delete.

2. Related knowledge

(1)The tables created by Lab4


(2)Insert, Update and Delete syntax.
Insert:

INSERT INTO table_name ( field1, field2,...fieldN )


VALUES( value1, value2,...valueN );

Update :

UPDATE table_name
SET column_name1 = new-value1,
column_name2=new-value2, ...
[WHERE Clause]

Delete :
DELETE FROM table_name WHERE condition;

3. Contents:

Note: all string and date/datetime type values should have ’’:
’James’ ’2001-03-22’
[Write SQL commands/statements and submit statements in a document file]
--1)Insert a new Student with student number(Id): s111, name: Machel, gender:M, birthday:2001-
03-22, other columns are NULL.
Insert a new Student with student number(Id): s112, name: Mary, gender:F, other columns are
NULL.
[Note: use INSERT INTO]
--2)Insert a new Course with course number(Id): c121, name: Machine Learning, credit: 3.5;
[Note: use INSERT INTO]
--3)Change Machel’s gender to F and Sphone to 155512345;
[Note: use UPDATE]

--4)Change Machine Learning course’s credit to 4.


[Note: use UPDATE]
--5)Delete student whose snum is s112; .
[Note: use DELETE]

--6)Delete Machine Learning course .


[Note: use DELETE]
.

You might also like