Skip to content

Commit

Permalink
JSON scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Brumm committed Aug 2, 2024
1 parent 3095791 commit 09eb406
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
Binary file modified .DS_Store
Binary file not shown.
33 changes: 33 additions & 0 deletions courses/course_postgres_mastery/38_json.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
JSON
*/

--SQL 01
CREATE TABLE test_json (
id INTEGER,
some_data JSON
);

--SQL 02
INSERT INTO test_json (id, some_data)
VALUES (1, '{"color":"blue"}');

--SQL 03
SELECT id, some_data
FROM test_json;

--SQL 04
CREATE TABLE test_jsonb (
id INTEGER,
some_data JSONB
);

--SQL 05
INSERT INTO test_jsonb (id, some_data)
VALUES (1, '{"color":"blue"}');

--SQL 06
SELECT id, some_data
FROM test_jsonb;


19 changes: 19 additions & 0 deletions courses/course_postgres_mastery/39_json_objects.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
JSON Objects
*/

--SQL 01
INSERT INTO test_jsonb (id, some_data)
VALUES (3, '{"color":"blue", "size":"large"}');

--SQL 02
SELECT id, some_data
FROM test_jsonb;

--SQL 03
INSERT INTO test_jsonb (id, some_data)
VALUES (3, '{"color":"white", "in_stock":"true"}');

--SQL 04
INSERT INTO test_jsonb (id, some_data)
VALUES (4, '{"color":"white", "in_stock":"false", "supplier":{"supplier_name":"ABC Corp", "email":"[email protected]"}}');
2 changes: 1 addition & 1 deletion videos/186_100m_mysql/mysql_queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The starting point of the video
This shows a cost of 13,251 with the medium_reviews file (approx 100k rows)
For 1m rows, cost is 142,267, time taken is 13 seconds
For 10m rows, cost is 1,533,828, time taken is 167 seconds
For 100m+ rows, cost is X, time taken is X
For 100m+ rows, cost is X, time taken is X (duration 2832 seconds, fetching 212 seconds, total 3044 seconds = 51 minutes
*/

SELECT
Expand Down

0 comments on commit 09eb406

Please sign in to comment.