Presentation is loading. Please wait.

Presentation is loading. Please wait.

Insert, Update, Delete Manipulating Data.

Similar presentations


Presentation on theme: "Insert, Update, Delete Manipulating Data."— Presentation transcript:

1 Insert, Update, Delete Manipulating Data

2 The Insert Command INSERT INTO Customer (Lastname, firstname, Phone)
VALUES (‘Smith’,’Joseph’,’ ’) INSERT puts a new row in a table The first parenthesis lists the columns names you wish to insert values into The actual values for those columns are placed in the parenthesis after the keyword values

3 Other Notes You can skip listing the column names if you are going to insert values into every table column in same sequence they have in the table Referential integrity may prevent an insert. You must insert into the One side of relation first Any foreign keys or required fields must be included in the insert

4 Update UPDATE is used to change the values in a given record or set of records UPDATE Customer SET LastName=‘Jones’ WHERE CustomerID=5

5 Updating Several Columns
UPDATE Customer SET Address=‘161 South North Street’, City=‘Bellevue’, Phone=‘ ’ WHERE CustomerID=6

6 Notes on Updates The WHERE clause is very important in UPDATE queries
If you do not specify a WHERE condition then all the rows in the table are updated to the new value Referential integrity rules also apply. You cannot change a foreign key to a value that would violate a relationship (to a value in other words that does not have a corresponding value in the one side of the relation.

7 DELETE DELETE always deletes a whole row.
DELETE FROM Customer WHERE CustomerID=5 DELETE always deletes a whole row. The WHERE Clause is extremely important If you don’t specify a WHERE clause the command will delete all the rows in the table Referential integrity rules must be obeyed. You can’t delete a value on the one side of a relation that has related records in another table

8 Updates and Deletes IMPORTANT THERE IS NO UNDO

9 DROP DELETE deletes records
To remove an object such as a table or a view you use the DROP keyword DROP TABLE Customer DROP DATABASE Cds Again there is no undo


Download ppt "Insert, Update, Delete Manipulating Data."

Similar presentations


Ads by Google