Creating, Reading, Updating and Deleting (CRUD)
Almost everything an application does to data is one of four operations, known as CRUD:
| Operation | SQL |
|---|---|
| Create | INSERT INTO table (cols) VALUES (...) |
| Read | SELECT cols FROM table WHERE ... |
| Update | UPDATE table SET col = value WHERE ... |
| Delete | DELETE FROM table WHERE ... |
Always include a WHERE on UPDATE and DELETE unless you truly mean every row. Always pass values as ? parameters, never by pasting them into the text. Changes are held until you commit() them to make them permanent.
Examplepython
Quick check
Which statement changes existing rows?
Your turn: write the code
Raise every price by 10 for products whose name is 'pen' and print the prices as a list ordered by id.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.