Difference between revisions of "Delete Queries"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
Line 16: Line 16:
 
* This process cannot be undone
 
* This process cannot be undone
 
* Not to be confused with DROP, for deleting columns and tables.
 
* Not to be confused with DROP, for deleting columns and tables.
 +
 +
===Basic Quiz===
 +
All these questions will use this table called Employees:
 +
 +
[[File:Capture.png]]
 +
<quiz display=simple>
 +
 +
{which of the following delete the record for 'Wonder Woman':
 +
 +
 +
|type="()"}
 +
+ Insert Into Employees ('First Name', 'Last Name', 'Address', 'City', 'Age') Values ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35)
 +
||Correct
 +
- Insert Into Employees ('First Name', 'Last Name', 'Address', 'City', 'Age') Data ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35)
 +
||Incorrect
 +
- Insert Into Employees ('First Name', 'Last Name', 'Address', 'Age', 'City') Data ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35)
 +
||Incorrect
 +
- Insert Into Employees ('First Name', 'Last Name', 'Address', 'Age', 'City') Values ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35)
 +
||Incorrect
 +
 +
</quiz>

Revision as of 11:32, 28 September 2020

Used for deleting rows from a table. The where section should give the criteria for deleting records, for example the specific ID for the record could be used. Alternatively the criteria could be more complex and use multiple criteria.

   DELETE FROM table WHERE column1=value1;

or:

   DELETE FROM table WHERE column1=value1 AND column2=value2;

Notes

  • Not specifying which records to delete will result in every record being deleted
  • The same can be achieved with 'DELETED * FROM table'
  • This process cannot be undone
  • Not to be confused with DROP, for deleting columns and tables.

Basic Quiz

All these questions will use this table called Employees:

Capture.png

1. which of the following delete the record for 'Wonder Woman':

Insert Into Employees ('First Name', 'Last Name', 'Address', 'City', 'Age') Values ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35)
Correct
Insert Into Employees ('First Name', 'Last Name', 'Address', 'City', 'Age') Data ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35)
Incorrect
Insert Into Employees ('First Name', 'Last Name', 'Address', 'Age', 'City') Data ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35)
Incorrect
Insert Into Employees ('First Name', 'Last Name', 'Address', 'Age', 'City') Values ('Joe', 'Bloggs', '1 Some Street', 'Sheffield', 35)
Incorrect

Your score is 0 / 0