Insert, Delete and update

Insert

The INSERT command is used as to add data to existing tables in a database. After specifying the table to insert into you can specify the fields you are entering data into and the order you will be entering the data. However, if you are entering data into all the fields in the correct order you don't need to do this like below.



The command above would create a new record in the player table for John Jones. The INSERT INTO command specifies the table where data will be inserted, and potentially which fields data will be provided for.

The VALUES command is where you specify values to enter. Strings should be in speech marks and dates between # tags.

Delete

The DELETE command is used as expected to delete records from a database table. You will receive a warning if you were to attempt to delete data that is relied on elsewhere such as one of the team names.

The DELETE FROM line is where you specify the table you wish to delete one or more records from.

The WHERE line lets you specify the condition under which a record should be deleted. Like with the SELECT method you can use Boolean and logical operators to make more complex conditions.

Update

The UPDATE command is used as to modify existing data in existing tables. After specifying the table with the data that you want to update you specify the fields and new values and the conditions under which to update the record.



The UPDATE line is where you specify the table where data needs to be updated.

The SET line is where you specify one or more fields and the new value they should receive.

The WHERE line allows you to specify criteria under which the update should be made. This allows you to update more than one record with the same command.

Knowledge check


Questions:
Correct:

Question text


© All materials created by and copyright S.Goff