-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtutorial.json
4367 lines (4367 loc) · 161 KB
/
tutorial.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"id": "freeCodeCamp/learn-relational-databases-by-building-a-mario-database:v1.0.0",
"version": "2.0.0",
"summary": {
"title": "Learn Relational Databases by Building a Mario Database",
"description": "> Welcome to the Relational Database Lessons!"
},
"config": {
"setup": {
"commands": [
"./.freeCodeCamp/reset.sh",
"cd .freeCodeCamp && npm install"
],
"commits": [
"e6e6ac52de4536ec17f4bb43b587d13a37778078"
]
},
"testRunner": {
"command": "npm run programmatic-test",
"args": {
"tap": "--reporter=mocha-tap-reporter"
},
"directory": ".freeCodeCamp"
},
"repo": {
"uri": "https://github.com/freeCodeCamp/learn-relational-databases-by-building-a-mario-database",
"branch": "v2.0.0"
},
"continue": {
"commands": [
"./.freeCodeCamp/reset.sh"
]
},
"reset": {
"commands": [
"./.freeCodeCamp/reset.sh"
]
},
"dependencies": [
{
"name": "node",
"version": ">=10"
}
],
"webhook": {
"url": "https://api.freecodecamp.org/coderoad-challenge-completed",
"events": {
"init": false,
"reset": false,
"step_complete": false,
"level_complete": false,
"tutorial_complete": true
}
}
},
"levels": [
{
"id": "10",
"title": "Start the Terminal",
"summary": "",
"content": "",
"steps": [
{
"id": "10.1",
"setup": {
"watchers": [
"../.bash_history"
],
"commits": [
"81aa8eea1a33def0cd3ce7aad1a5ddf65c18783a"
]
},
"content": "**The first thing you need to do is start the terminal.** Do that by clicking the \"hamburger\" menu at the top left of the screen, going to the \"terminal\" section, and clicking \"new terminal\". Once you open a new one, type `echo hello PostgreSQL` into the terminal and press enter.",
"hints": [
"Capitalization matters",
"If the tests don't run automatically, try typing `exit` into the terminal and redoing the instructions"
]
}
]
},
{
"id": "20",
"title": "Login",
"summary": "",
"content": "",
"steps": [
{
"id": "20.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"b779cf360edd397ff103562e645c762ebbbd7111"
]
},
"content": "Your virtual machine comes with PostgreSQL installed. You will use the Psql terminal application to interact with it. Log in by typing `psql --username=freecodecamp --dbname=postgres` into the terminal and pressing enter.",
"hints": [
"Capitalization matters",
"Type `psql --username=freecodecamp --dbname=postgres` into the terminal and press enter",
"If the terminal isn't open, find the \"hamburger\" menu at the top left of the window, navigate to the \"Terminal\" tab, and click \"New Terminal\""
]
}
]
},
{
"id": "30",
"title": "View Databases",
"summary": "",
"content": "",
"steps": [
{
"id": "30.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"9894c375e17529075e56633e3ad1a66f42e1f63c"
]
},
"content": "Notice that the prompt changed to let you know that you are now interacting with PostgreSQL. First thing to do is see what databases are here. Type `\\l` into the prompt to **l**ist them.",
"hints": [
"Type `\\l` into the psql prompt and press enter",
"Type `psql --username=freecodecamp --dbname=postgres` into the terminal to log in to psql if you aren't logged in first"
]
}
]
},
{
"id": "40",
"title": "Create `first_database`",
"summary": "",
"content": "",
"steps": [
{
"id": "40.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"9b6958f91d2913e1cddfcfe7829690e1401b04bd"
]
},
"content": "The databases you see are there by default. You can make your own like this:\n\n```sql\nCREATE DATABASE database_name;\n```\n\nThe capitalized words are keywords telling PostgreSQL what to do. The name of the database is the lowercase word. Note that **all commands need a semi-colon at the end.** Create a new database named `first_database`.",
"hints": [
"Don't forget the semi-colon at the end",
"Type `CREATE DATABASE first_database;` into the psql prompt and press enter",
"Type `psql --username=freecodecamp --dbname=postgres` into the terminal to log in to psql if you aren't logged in first"
]
}
]
},
{
"id": "50",
"title": "View `first_database`",
"summary": "",
"content": "",
"steps": [
{
"id": "50.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"a3b4b9df39ad88c1b7ef3d5958bb17f7a0748918"
]
},
"content": "Use the **l**ist shortcut command again to make sure your new database is there.",
"hints": [
"Type `\\` followed by the \"list\" shortcut letter",
"Enter `\\l` into the psql prompt and press enter",
"Type `psql --username=freecodecamp --dbname=postgres` into the terminal to log in to psql if you aren't logged in first"
]
}
]
},
{
"id": "60",
"title": "Create `second_database`",
"summary": "",
"content": "",
"steps": [
{
"id": "60.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"11e30a273c0113ec10e93ff48d21e7f2a1ba880c"
]
},
"content": "It worked. Your new database is there. If you don't get a message after entering a command, it means it's incomplete and you likely forgot the semi-colon. You can just add it on the next line and press enter to finish the command. Create another database named `second_database`.",
"hints": [
"Use the \"CREATE DATABASE\" keywords",
"Here's the example again: `CREATE DATABASE database_name;`",
"Don't forget the semi-colon",
"Try entering `CREATE DATABASE second_database;`",
"Type `psql --username=freecodecamp --dbname=postgres` into the terminal to log in to psql if you aren't logged in first"
]
}
]
},
{
"id": "70",
"title": "View Databases",
"summary": "",
"content": "",
"steps": [
{
"id": "70.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"9dcdcb698324b34c979adbf73c7cf68c9dadc7d0"
]
},
"content": "You should have another new database now. **L**ist the databases to make sure.",
"hints": [
"Use the **l**ist shortcut command",
"Enter `\\l` into the prompt",
"Type `psql --username=freecodecamp --dbname=postgres` into the terminal to log in to psql if you aren't logged in first"
]
}
]
},
{
"id": "80",
"title": "Connect to `second_database`",
"summary": "",
"content": "",
"steps": [
{
"id": "80.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"8c9b5d5a370afe33f10246b84ca57324b5e1aa22"
]
},
"content": "You can **c**onnect to a database by entering `\\c database_name`. You need to connect to add information. Connect to your `second_database`.",
"hints": [
"Enter `\\c second_database` into the psql prompt to connect",
"Type `psql --username=freecodecamp --dbname=postgres` into the terminal to log in to psql if you aren't logged in first"
]
}
]
},
{
"id": "90",
"title": "View `second_database` Tables",
"summary": "",
"content": "",
"steps": [
{
"id": "90.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"d2498afc85755a3f56702f2eb766be71a324a088"
]
},
"content": "You should see a message that you are connected. Notice that the prompt changed to `second_database=>`. So the `postgres=>` prompt before must have meant you were connected to that database. A database is made of tables that hold your data. Enter `\\d` to **d**isplay the tables.",
"hints": [
"Type `\\d` in the prompt and press enter",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "100",
"title": "Create `first_table`",
"summary": "",
"content": "",
"steps": [
{
"id": "100.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"80c41723cbc6ba6e388b6b9ad586fb51be01e2f9"
]
},
"content": "Looks like there's no tables or relations yet. Similar to how you created a database, you can create a table like this:\n\n```sql\nCREATE TABLE table_name();\n```\n\nNote that the parenthesis are needed for this one. It will create the table in the database you are connected to. Create a table named `first_table` in `second_database`.",
"hints": [
"Enter `CREATE TABLE first_table();` into the prompt",
"Don't forget the semi-colon",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "110",
"title": "View `second_database` Tables",
"summary": "",
"content": "",
"steps": [
{
"id": "110.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"58d2a65bde310059432cd6e30875deecc66c21bc"
]
},
"content": "View the tables in `second_database` again with the **d**isplay command. You should see your new table there with a little meta data about it.",
"hints": [
"Use the **d**isplay shortcut command",
"Try entering `\\d` into the prompt",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "120",
"title": "Create `second_table`",
"summary": "",
"content": "",
"steps": [
{
"id": "120.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"a0a502ff750281ad17f09f424cd7284d9dd3cc72"
]
},
"content": "Create another new table in this database. Give it a name of `second_table`.",
"hints": [
"Use the \"CREATE TABLE\" keywords",
"Don't forget the parenthesis and semi-colon at the end",
"Here's an example: `CREATE TABLE table_name();`",
"Enter `CREATE TABLE second_table();` into the prompt",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "130",
"title": "View `second_database` Tables",
"summary": "",
"content": "",
"steps": [
{
"id": "130.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"9166f15fab5ec5ea0fe00eb3f2ac2fac9a0fb705"
]
},
"content": "There should be two tables in this database now. **D**isplay them again to make sure.",
"hints": [
"Use the **display** shortcut command",
"Enter `\\d` into the prompt",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "140",
"title": "View `second_table` Details",
"summary": "",
"content": "",
"steps": [
{
"id": "140.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"8a69253dd1389c44301019a4ec70c514674ff628"
]
},
"content": "You can view more details about a table by adding the table name after the **d**isplay command like this: `\\d table_name`. View more details about your `second_table`.",
"hints": [
"Enter `\\d second_table` into the prompt",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "150",
"title": "Create `first_column`",
"summary": "",
"content": "",
"steps": [
{
"id": "150.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"090c07566895cf2aa117704a32beee18b68d97c6"
]
},
"content": "Tables need **columns** to describe the data in them, yours doesn't have any yet. Here's an example of how to add one:\n\n```sql\nALTER TABLE table_name ADD COLUMN column_name DATATYPE;\n```\n\nAdd a column to `second_table` named `first_column`. Give it a data type of `INT`. `INT` stands for integer. Don't forget the semi-colon. :smile:",
"hints": [
"Try entering `ALTER TABLE second_table ADD COLUMN first_column INT;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "160",
"title": "View `second_table` Details",
"summary": "",
"content": "",
"steps": [
{
"id": "160.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"8382a78d808a0b1d7b8f2cbe65bdd4dc88a799cc"
]
},
"content": "Looks like it worked. **D**isplay the details of `second_table` again to see if your new column is there.",
"hints": [
"Use the **d**isplay shortcut command",
"Put the table name after the command",
"Here's an example: `\\d table_name`",
"Try entering `\\d second_table`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "170",
"title": "Add `id` Column",
"summary": "",
"content": "",
"steps": [
{
"id": "170.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"2dd882e4af46f32b0377d6ae9e476cfa93013a22"
]
},
"content": "Your column is there :smile: Use `ALTER TABLE` and `ADD COLUMN` to add another column to `second_table` named `id` that's a type of `INT`.",
"hints": [
"Here's the example again: `ALTER TABLE table_name ADD COLUMN column_name DATATYPE;`",
"Don't forget the semi-colon :wink:",
"You added the last column with: `ALTER TABLE second_table ADD COLUMN first_column INT;`",
"Try entering `ALTER TABLE second_table ADD COLUMN id INT;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "180",
"title": "View `second_table` Details",
"summary": "",
"content": "",
"steps": [
{
"id": "180.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"6244d6a474f951a403f9621dcf4f115b2b7235c8"
]
},
"content": "Your table should have an `id` column added. View the details of `second_table` to make sure.",
"hints": [
"Use the **d**isplay command",
"Add a table name after the **d**isplay command to view details",
"Here's an example: `\\d table_name`",
"Try entering `\\d second_table`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "190",
"title": "Add `age` Column",
"summary": "",
"content": "",
"steps": [
{
"id": "190.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"791924cb000b65b3028ecfe707cd1c3a69065afd"
]
},
"content": "Add another column to `second_table` named `age`. Give it a data type of `INT`.",
"hints": [
"Use the `ALTER TABLE` and `ADD COLUMN` keywords",
"Here's the example again: `ALTER TABLE table_name ADD COLUMN column_name DATATYPE;`",
"You added the last column with: `ALTER TABLE second_table ADD COLUMN id INT;`",
"Try using `ALTER TABLE second_table ADD COLUMN age INT;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "200",
"title": "View `second_table` Details",
"summary": "",
"content": "",
"steps": [
{
"id": "200.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"e00d7049958152116bac6f3308521fc9275fad85"
]
},
"content": "Take a look at the details of `second_table` again.",
"hints": [
"Use the **d**isplay shortcut command",
"Add the table name to the shortcut command to see details",
"Here's an example: `\\d table_name`",
"Enter `\\d second_table`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "210",
"title": "Drop `age` Column",
"summary": "",
"content": "",
"steps": [
{
"id": "210.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"625133713bf8e3a2f40ac8aaa317a8312d91f7f2"
]
},
"content": "Those are some good looking columns. You will probably need to know how to remove them. Here's an example:\n\n```sql\nALTER TABLE table_name DROP COLUMN column_name;\n```\n\nDrop your `age` column.",
"hints": [
"Try entering `ALTER TABLE second_table DROP COLUMN age;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "220",
"title": "View `second_table` Details",
"summary": "",
"content": "",
"steps": [
{
"id": "220.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"e8fa0ea3dae760813168a616a85eafb63fc1dd3e"
]
},
"content": "View the details of `second_table` to see if it's gone.",
"hints": [
"Use the **d**isplay shortcut command",
"Add the table name to the shortcut command to see details",
"Here's an example: `\\d table_name`",
"Enter `\\d second_table`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "230",
"title": "Drop `first_column` Column",
"summary": "",
"content": "",
"steps": [
{
"id": "230.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"7b8713b8783f868797a763cad7b5d6101ef376bb"
]
},
"content": "It's gone. Use the `ALTER TABLE` and `DROP COLUMN` keywords again to drop `first_column`.",
"hints": [
"Here's the example again: `ALTER TABLE table_name DROP COLUMN column_name;`",
"You dropped the last column with: `ALTER TABLE second_table DROP COLUMN age;`",
"Try entering `ALTER TABLE second_table DROP COLUMN first_column;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "240",
"title": "Add `name` Column",
"summary": "",
"content": "",
"steps": [
{
"id": "240.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"e21edb248a9d53654301ee7769e0a848457392aa"
]
},
"content": "A common data type is `VARCHAR`. It's a short string of characters. You need to give it a maximum length when using it like this: `VARCHAR(30)`.\n\nAdd a new column to `second_table`, give it a name of `name` and a data type of `VARCHAR(30)`.",
"hints": [
"Use the `ALTER TABLE` and `ADD COLUMN` keywords",
"Here's an example: `ALTER TABLE table_name ADD COLUMN column_name DATATYPE;`",
"You added the last column like this: `ALTER TABLE second_table ADD COLUMN age INT;`",
"Try entering `ALTER TABLE second_table ADD COLUMN name VARCHAR(30);`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "250",
"title": "View `second_table` Details",
"summary": "",
"content": "",
"steps": [
{
"id": "250.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"5216b8f9a51bbf2fb7f73b355e93a83c654acec3"
]
},
"content": "Take a look at the details of `second_table` to see your columns.",
"hints": [
"Use the **d**isplay shortcut command",
"Here's an example: `\\d table_name`",
"Try entering `\\d second_table`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "260",
"title": "Rename `name` Column",
"summary": "",
"content": "",
"steps": [
{
"id": "260.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"1f081d505b8e75924bbef4ae1912c1ab51465f3f"
]
},
"content": "You can see the `VARCHAR` type there. The `30` means the data in it can be a max of 30 characters. You named that column `name`, it should have been `username`. Here's how you can rename a column:\n\n```sql\nALTER TABLE table_name RENAME COLUMN column_name TO new_name;\n```\n\nRename the `name` column to `username`.",
"hints": [
"Use `second_table` as the table name, `name` as the column name, and `username` as the new name for the column",
"Try entering `ALTER TABLE second_table RENAME COLUMN name TO username;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "270",
"title": "View `second_table` Details",
"summary": "",
"content": "",
"steps": [
{
"id": "270.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"1cbef48510ec1f17499b3dd9e6ef816d6863d547"
]
},
"content": "Take a look at the details of `second_table` again to see if it got renamed.",
"hints": [
"Use the **d**isplay shortcut command",
"Here's an example: `\\d table_name`",
"Enter `\\d second_table`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "280",
"title": "Insert Samus Row",
"summary": "",
"content": "",
"steps": [
{
"id": "280.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"3d3a5cea4cb868d95d5aee201da5631eb8579987"
]
},
"content": "It worked. Rows are the actual data in the table. You can add one like this:\n\n```sql\nINSERT INTO table_name(column_1, column_2) VALUES(value1, value2);\n```\n\nInsert a row into `second_table`. Give it an `id` of `1`, and a `username` of `Samus`. The username column expects a `VARCHAR`, so you need to put Samus in single quotes like this: `'Samus'`.",
"hints": [
"The table is `second_table`, the column names are `id` and `username`, and the values to add are `1` and `'Samus'`",
"Don't forget the semi-colon",
"Try entering `INSERT INTO second_table(id, username) VALUES(1, 'Samus');`",
"If you missed a matching single quote, try entering `');` to finish the command and try again",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "290",
"title": "View `second_table` Data",
"summary": "",
"content": "",
"steps": [
{
"id": "290.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"1f47f6efd5b85c1026602d25f1038a5dfcab62db"
]
},
"content": "You should have one row in your table. You can view the data in a table by querying it with the `SELECT` statement. Here's how it looks:\n\n```sql\nSELECT columns FROM table_name;\n```\n\nUse a `SELECT` statement to view **all** the columns in `second_table`. Use an asterisk (`*`) to denote that you want to see all the columns.",
"hints": [
"Replace `columns` in the example with the all (`*`) symbol",
"Use `second_table` as the table name",
"Enter `SELECT * FROM second_table;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "300",
"title": "Insert Mario Row",
"summary": "",
"content": "",
"steps": [
{
"id": "300.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"9077b27fb6fbee0c48cf46e46ee85592a668b054"
]
},
"content": "There's your one row. **Insert** another row **into** `second_table`. Fill in the `id` and `username` columns with the **values** `2` and `'Mario'`.",
"hints": [
"Here's the example: `INSERT INTO table_name(column_1, column_2) VALUES(value1, value2);`",
"Did you make `Mario` a string?",
"You added the last row with `INSERT INTO second_table(id, username) VALUES(1, 'Samus');`",
"Try entering `INSERT INTO second_table(id, username) VALUES(2, 'Mario');`",
"If you missed a matching single quote, try entering `');` to finish the command",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "310",
"title": "View `second_table` Data",
"summary": "",
"content": "",
"steps": [
{
"id": "310.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"16af467acbadd1a4b922f5480c99e6b9b3161e29"
]
},
"content": "You should now have two rows in the table. Use `SELECT` again to view **all** the columns and rows **from** `second_table`.",
"hints": [
"Here's the example: `SELECT columns FROM table_name;`",
"Use `*` to see all columns",
"Try entering `SELECT * FROM second_table;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "320",
"title": "Insert Luigi Row",
"summary": "",
"content": "",
"steps": [
{
"id": "320.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"fc7bbf107d4b4fc0f42441d08c73539be41b43e0"
]
},
"content": "**Insert** another row **into** `second_table`. Use `3` as the `id`, and `Luigi` as the `username` this time.",
"hints": [
"Did you put `Luigi` in single quotes?",
"Here's the example: `INSERT INTO table_name(column_1, column_2) VALUES(value1, value2);`",
"You added the last row with `INSERT INTO second_table(id, username) VALUES(2, 'Mario');`",
"Try entering `INSERT INTO second_table(id, username) VALUES(3, 'Luigi');`",
"If you missed a matching single quote, try entering `');` to finish the command",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "330",
"title": "View `second_table` Data",
"summary": "",
"content": "",
"steps": [
{
"id": "330.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"fc0d782a7b55523652e557ea575d2662b483b7b3"
]
},
"content": "You should now have three rows. Use `SELECT` again to see **all** the data you entered.",
"hints": [
"Here's the example again: `SELECT columns FROM table_name;`",
"Use `*` to see all columns",
"Try entering `SELECT * FROM second_table;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "340",
"title": "Delete Luigi Row",
"summary": "",
"content": "",
"steps": [
{
"id": "340.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"035090d15ef03b44ff256dbf0943a795bf8a9e46"
]
},
"content": "That gives me an idea :smiley: You can make a database of Mario video game characters. You should start from scratch for it. Why don't you delete the record you just entered. Here's an example of how to delete a row:\n\n```sql\nDELETE FROM table_name WHERE condition;\n```\n\nRemove Luigi from your table. The condition you want to use is `username='Luigi'`.",
"hints": [
"Check your table name and condition closely",
"Try entering `DELETE FROM second_table WHERE username='Luigi';`",
"If you missed a matching single quote, try entering `');` to finish the command",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "350",
"title": "View `second_table` Data",
"summary": "",
"content": "",
"steps": [
{
"id": "350.1",
"setup": {
"watchers": [
"../pg.log"
],
"commits": [
"6d67f9a465537977c6c923dd59a72f2e5644d68a"
]
},
"content": "Luigi should be gone. Use `SELECT` again to see all the data and make sure he's not there.",
"hints": [
"Here's the example: `SELECT columns FROM table_name;`",
"Use `*` to see all the columns",
"Try `SELECT * FROM second_table;`",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "360",
"title": "Delete Mario Row",
"summary": "",
"content": "",
"steps": [
{
"id": "360.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"81050c95a75d3cbab5df6e3b0dad8c03b44b0216"
]
},
"content": "It's gone. You can scrap all this for the new database. **Delete** Mario **from** `second_table` using the same command as before, except make the condition `username='Mario'` this time.",
"hints": [
"Use the `DELETE FROM` and `WHERE` keywords",
"Here's the example: `DELETE FROM table_name WHERE condition;`",
"You deleted Luigi with `DELETE FROM second_table WHERE username='Luigi';`",
"Try entering `DELETE FROM second_table WHERE username='Mario';`",
"If you missed a matching single quote, try entering `');` to finish the command",
"Enter `psql --username=freecodecamp --dbname=second_database` into the terminal to log in if you aren't already"
]
}
]
},
{
"id": "370",
"title": "Delete Samus Row",
"summary": "",
"content": "",
"steps": [
{
"id": "370.1",
"setup": {
"watchers": [
"../queryResults.log"
],
"commits": [
"386fdc0c1dbf53c1eccb03d0ae8b65a69828ef38"