1 / 13

DATA MANIPULATION LANGUAGE (DML)

DATA MANIPULATION LANGUAGE (DML). DATA MANIPULATION. There are the standard Data Manipulation Language (DML) elements. DML is the subset of the language used to add, update and delete data: INSERT DELETE UPDATE. INSERT.

Télécharger la présentation

DATA MANIPULATION LANGUAGE (DML)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DATA MANIPULATION LANGUAGE (DML)

  2. DATA MANIPULATION • There are the standard Data Manipulation Language (DML) elements. • DML is the subset of the language used to add, update and delete data: • INSERT • DELETE • UPDATE

  3. INSERT • INSERT is used to add rows (formally tuples) to an existing table, for example: SYNTAX INSERT INTO "table_name" ("column1", "column2", ...)VALUES ("value1", "value2", ...)

  4. SQL INSERT STATEMENT Example INSERT INTO Employees VALUES ( ‘05 ’,’Vasquez, Djoanna Marie’) INSERT INTO Employees (Name) VALUES (‘Vasquez, Djoanna Marie ’)

  5. SQL DELETE STATEMENT • DELETE removes zero or more existing rows from a table DELETE FROM "table_name"WHERE {condition} Example: DELETE FROM Orders Where Product =‘Printer’

  6. DELETE ALL ROWS • 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 DELETE FROM table_name Or DELETE * FROM table_name

  7. SQL UPDATE Statement • UPDATE is used to modify the values of a set of existing table rows Syntax UPDATE table_name SET column_name = new_value WHERE column_name = some_value

  8. Person We want to add a first name to the person with a last name of "Rasmussen": UPDATE Person SET FirstName = 'Nina‘ WHERE LastName = 'Rasmussen‘ Result:

  9. Update Several Columns in a Row We want to change the address and add the name of the city: UPDATE PersonSET Address = 'Stien 12', City = 'Stavanger‘ WHERE LastName = 'Rasmussen‘ Result

  10. EXERCISES

  11. Exercises • Insert the following records in the Branch table. (B009, 34 Fish Rd, Aberdeen) • Insert the following records in the Properties table.(PG18, 56 Lawrence St, Glasgow, House, 3, 700) • Delete all houses located in Glasgow. • Delete all properties whose number of rooms is greater than 4 • Delete all the records in the Branch table.

  12. 6. Delete all staff who was born from 1958 to 1970 7. Change the last name of Mary Howe to Mary White 8. Increase the salary of all employees by 5% 9. Increase the salary of Assistants by 5% 10.Change all properties to houses whose type is flat and located in Glasgow

  13. GOOD DAY!!! HOPE YOU HAVE LEARNED SOMETHING TODAY..

More Related