Sie sind auf Seite 1von 5

CRUD

for T-Shirts on MySQL



CREATE

Create a database called shirts_db



Create a table called shirts with the following variables: shirt_id, article, color, shirt_size, and
last_worn where shirt_id is mandatory



Insert the data into the shirts table


Add a new shirt into the shirts table as shirt number 9



READ

Now we are going to read the data. First select all shirts but only print out article and color.



Select all medium shirts and print out everything except shirt_id


UPDATE

Update all polo shirt size to L



Update the shirt last worn 15 days ago to last worn 0. To do so, we need to find the shirt(s) that
ha(ve)s last worn 0 days ago and the shirt(s) that ha(ve)s last worn 15 days ago.



We are expecting tanks last worn status to 0 from 15 after the update.


Update all white shirts and change their size to XS and color to off white. First, we need to
check which shirts are white.



Knowing that shirts 1 and 7 are white, we can now update the shirts to off white and XS.



DELETE

Delete all old shirts last worn 200 days ago



Delete all tank tops, but first find all the tank tops we have in the shirts table


Delete the tank tops, so we expect to see that shirt_ids 4 and 8 are gone



Delete all shirts. The table is supposed to be empty when we try to read the shirts table again.



Drop the entire shirts table



This table has been deleted from the shirts_db, so now the database is empty.

Das könnte Ihnen auch gefallen