-
Notifications
You must be signed in to change notification settings - Fork 186
Solved! #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Solved! #189
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,19 @@ | ||
| -- Use our database | ||
| USE ShopDB; | ||
| USE ShopDB; | ||
|
|
||
| -- Some data should be created outside the transaction (here) | ||
| -- ShopDB should be created by running create-database.sql before this script. | ||
| -- AwersomeProduct with ID 1 and customer with ID 1 are inserted there as initial data. | ||
|
|
||
| -- Start the transaction | ||
| START TRANSACTION; | ||
| INSERT INTO Orders (CustomerID, Date) | ||
| VALUES (1, '2023-01-01'); | ||
|
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| -- And some data should be created inside the transaction | ||
| -- Start the transaction | ||
| START TRANSACTION; | ||
|
|
||
| COMMIT; | ||
| INSERT INTO OrderItems (OrderID, ProductID, Count) | ||
| VALUES (1, 1, 1); | ||
|
|
||
| UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 | ||
| WHERE ID = 1; | ||
|
|
||
| COMMIT; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The task requires dropping and recreating the
ShopDBdatabase usingDROP DATABASE ShopDB;and thecreate-database.sqlscript. Currently, onlyUSE ShopDB;is present, which assumes the database already exists. AddDROP DATABASE IF EXISTS ShopDB;andCREATE DATABASE ShopDB;statements before theUSEstatement.