Week 6
Week 6
SQL III
DML-Data Manipulation Language
Pınar Yıldırım
The SQL INSERT INTO Statement
• The INSERT INTO statement is used to insert new records in a table.
• INSERT INTO Syntax
– the INSERT INTO statement can be written in two ways.
– The first way specifies both the column names and the values to be
inserted:
– INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
The SQL INSERT INTO Statement
• In order to add values for all the columns of the table, not need to specify
the column names in the SQL query. But, the order of the values should
be in the same order as the columns in the table. The INSERT INTO syntax
would be as follows:
• UPDATE Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
The SQL UPDATE Statement
• Not: The WHERE clause specifies which record(s) that should be updated.
If the WHERE clause is omitted, all records in the table will be updated!
UPDATE Example
• UPDATE Customers
SET CustomerName = ‘Deniz', City= ‘İzmir'
WHERE CustomerID = 391;
• DELETE Syntax
DELETE FROM table_name WHERE condition;
SQL DELETE Statement
• The following SQL statement deletes all rows in the "Customers" table,
without deleting the table:
• Example
DELETE FROM Customers;
References
• Modern Database Management 11th Edition, Jeffrey A. Hoffer, V. Ramesh,
Heikki Topi © 2013 Pearson Education, Inc. Publishing as Prentice Hall
• https://www.w3schools.com