diff --git a/.vscode/settings.json b/.vscode/settings.json index 375aedb..62fdbf9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -26,7 +26,7 @@ "port": 3306, "driver": "MySQL", "name": "mysql", - "database": "default", + "database": "gym", "username": "root", "askForPassword": true }, @@ -36,7 +36,7 @@ "port": 5432, "driver": "PostgreSQL", "name": "postgresql", - "database": "default", + "database": "gym", "username": "postgres", "askForPassword": true } diff --git a/data/01-transaction.sql b/data/01-transaction.sql new file mode 100644 index 0000000..c43619c --- /dev/null +++ b/data/01-transaction.sql @@ -0,0 +1 @@ +-- Transactions in MySQL diff --git a/data/01.1-start-transaction.sql b/data/01.1-start-transaction.sql new file mode 100644 index 0000000..dbe7c6a --- /dev/null +++ b/data/01.1-start-transaction.sql @@ -0,0 +1 @@ +START TRANSACTION; diff --git a/data/01.2-insert-customers.sql b/data/01.2-insert-customers.sql new file mode 100644 index 0000000..48732d8 --- /dev/null +++ b/data/01.2-insert-customers.sql @@ -0,0 +1,4 @@ +INSERT INTO customers(first_name, last_name, email) +VALUES('Maria', 'Jones', 'maria@test.com'); + +SAVEPOINT save_1; diff --git a/data/01.3-insert-orders.sql b/data/01.3-insert-orders.sql new file mode 100644 index 0000000..6f098b7 --- /dev/null +++ b/data/01.3-insert-orders.sql @@ -0,0 +1,2 @@ +INSERT INTO orders(amount_billed, customer_id) +VALUES(103.12); diff --git a/data/01.4-rollback.sql b/data/01.4-rollback.sql new file mode 100644 index 0000000..0b174c5 --- /dev/null +++ b/data/01.4-rollback.sql @@ -0,0 +1 @@ +ROLLBACK TO save_1; diff --git a/data/01.5-commit.sql b/data/01.5-commit.sql new file mode 100644 index 0000000..87ef767 --- /dev/null +++ b/data/01.5-commit.sql @@ -0,0 +1 @@ +COMMIT; diff --git a/data/02-transaction.sql b/data/02-transaction.sql new file mode 100644 index 0000000..520da95 --- /dev/null +++ b/data/02-transaction.sql @@ -0,0 +1 @@ +-- Transactions in PostgreSQL diff --git a/data/02.1-start-transaction.sql b/data/02.1-start-transaction.sql new file mode 100644 index 0000000..1775571 --- /dev/null +++ b/data/02.1-start-transaction.sql @@ -0,0 +1 @@ +BEGIN; diff --git a/data/02.2-insert-customers.sql b/data/02.2-insert-customers.sql new file mode 100644 index 0000000..8761ac7 --- /dev/null +++ b/data/02.2-insert-customers.sql @@ -0,0 +1,2 @@ +INSERT INTO customers(first_name, last_name, email) +VALUES('Maria', 'Jones', 'maria@test.com'); diff --git a/data/02.3-insert-orders.sql b/data/02.3-insert-orders.sql new file mode 100644 index 0000000..6f098b7 --- /dev/null +++ b/data/02.3-insert-orders.sql @@ -0,0 +1,2 @@ +INSERT INTO orders(amount_billed, customer_id) +VALUES(103.12); diff --git a/data/02.4-rollback.sql b/data/02.4-rollback.sql new file mode 100644 index 0000000..3b18e77 --- /dev/null +++ b/data/02.4-rollback.sql @@ -0,0 +1 @@ +ROLLBACK; diff --git a/data/02.5-commit.sql b/data/02.5-commit.sql new file mode 100644 index 0000000..87ef767 --- /dev/null +++ b/data/02.5-commit.sql @@ -0,0 +1 @@ +COMMIT; diff --git a/disclaimer.txt b/disclaimer.txt new file mode 100644 index 0000000..9b90f5b --- /dev/null +++ b/disclaimer.txt @@ -0,0 +1,4 @@ +# Database + +The 'gym' database (created in section 6) will be used. +Make sure run the commands to create the tables and insert data.