0% found this document useful (0 votes)
44 views2 pages

Data Manipulation Language

The document discusses SQL insert, update, and delete clauses. It provides the syntax for each clause and notes that: - For insert, the number of column values must equal the number of table columns and be the same type. - For update, it is not possible to update multiple tables in one query and new values must satisfy column constraints. - For delete, when no conditions are specified, all table records will be removed, equivalent to using TRUNCATE. The document then provides examples to test understanding of using each clause with specific customer and order tables.

Uploaded by

Yesmine Makkes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

Data Manipulation Language

The document discusses SQL insert, update, and delete clauses. It provides the syntax for each clause and notes that: - For insert, the number of column values must equal the number of table columns and be the same type. - For update, it is not possible to update multiple tables in one query and new values must satisfy column constraints. - For delete, when no conditions are specified, all table records will be removed, equivalent to using TRUNCATE. The document then provides examples to test understanding of using each clause with specific customer and order tables.

Uploaded by

Yesmine Makkes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Insert into clause

Implicit Insert: Insert in all table columns


INSERT INTO table_name VALUES
(
value_column1,
value_column2,
...,
value_columnn
);

The number of column values must be equal to the number of table columns and of the same types

Insert into clause


Explicit Insert: Insert in a specified list of columns
INSERT INTO table_name
(
column1,
column2,
column3
)
VALUES
(
value_column1,
value_column2,
value_column3
);

Insert into Clause


• The values to be added must verify the defined constraints on the columns table.
• Any record which does not verify the constraints will be rejected.
• The columns created with NOT NULL constraint must have values.
• We can use the following syntax to insert data from table.
INSERT INTO table_name (column1,column2)
SELECT column1, column2 from table_name1;

Which of the following instructions is correct to insert the following values in these tables
Customers (CustCode, custName, custAdress, custTel) Orders (OrderCode, OrderDate, #CustCode)
(( https://i.imgur.com/E2SfXdO.png ))
https://i.imgur.com/3eyFDbO.png

Update clause
Syntax:
UPDATE table_name SET column_name=new_value
[WHERE (conditions)];
It is not possible to update several tables in the same query.
The new values must satisfy the columns constraints
When there is no conditions in the query, then all the table rows will be updated with the same
value.
Which of the following is correct to update the address of the customer CO1 to ‘Sousse’ and the
date of the Order 101 to ‘22/10/2019’ Customers (CustCode, custName, custAdress, custTel) Orders
(OrderCode, OrderDate, #CustCode) ((( https://i.imgur.com/NDIDw22.png )))
https://i.imgur.com/7ENlLFe.png

Delete clause
Syntax:
DELETE FROM table_name [WHERE (conditions)];

When there is no conditions in the query, then all the table records will be removed, which will be
equivalent to run this command:
TRUNCATE FROM table_name;

Which of the following is correct to remove the client ‘C01’ from the customers table
Customers (CustCode, custName, custAdress, custTel) https://i.imgur.com/OI31IUP.png
https://i.imgur.com/oK2FuW9.png

You might also like