· 6 years ago · May 07, 2019, 12:40 AM
1shihc@DESKTOP-29R83UR MINGW64 /
2$ pg_ctl start
3waiting for server to start....2019-04-25 20:04:01.480 PDT [13568] LOG: listening on IPv6 address "::", port 5432
42019-04-25 20:04:01.480 PDT [13568] LOG: listening on IPv4 address "0.0.0.0", port 5432
52019-04-25 20:04:01.505 PDT [13568] LOG: redirecting log output to logging collector process
62019-04-25 20:04:01.505 PDT [13568] HINT: Future log output will appear in directory "log".
7 done
8server started
9
10shihc@DESKTOP-29R83UR MINGW64 /
11$ psql -U dunder_mifflin_admin -d restaurants-app -f ~/Downloads/nyc-restaurants-data-backup.sql
12Password for user dunder_mifflin_admin:
13psql: fe_sendauth: no password supplied
14
15shihc@DESKTOP-29R83UR MINGW64 /
16$ psql -U dunder_mifflin_admin -d restaurants-app -f ~/Downloads/nyc-restaurants-data-backup.sql
17Password for user dunder_mifflin_admin:
18psql: FATAL: password authentication failed for user "dunder_mifflin_admin"
19
20shihc@DESKTOP-29R83UR MINGW64 /
21$ psql -U postgres -d restaurants-app -f ~/Desktop/nyc-restaurants-data-backup.sql
22psql: FATAL: database "restaurants-app" does not exist
23
24shihc@DESKTOP-29R83UR MINGW64 /
25$ psql -U postgres -d restaurants_app -f ~/Desktop/nyc-restaurants-data-backup.sql
26SET
27SET
28SET
29SET
30SET
31SET
32SET
33SET
34CREATE EXTENSION
35COMMENT
36SET
37CREATE TYPE
38SET
39SET
40CREATE TABLE
41CREATE SEQUENCE
42ALTER SEQUENCE
43CREATE TABLE
44CREATE SEQUENCE
45ALTER SEQUENCE
46ALTER TABLE
47ALTER TABLE
48COPY 93450
49 setval
50--------
51 93463
52(1 row)
53
54
55COPY 25359
56 setval
57--------
58 25359
59(1 row)
60
61
62ALTER TABLE
63ALTER TABLE
64ALTER TABLE
65
66shihc@DESKTOP-29R83UR MINGW64 /
67$ \dt+
68bash: dt+: command not found
69
70shihc@DESKTOP-29R83UR MINGW64 /
71$ pg_ctl status
72pg_ctl: server is running (PID: 13568)
73C:/Program Files/PostgreSQL/11/bin/postgres.exe
74
75shihc@DESKTOP-29R83UR MINGW64 /
76$ psql
77psql (11.2)
78WARNING: Console code page (437) differs from Windows code page (1252)
79 8-bit characters might not work correctly. See psql reference
80 page "Notes for Windows users" for details.
81Type "help" for help.
82
83postgres=# \dt+
84Did not find any relations.
85postgres=# \du
86 List of roles
87 Role name | Attributes | Member of
88----------------------+------------------------------------------------------------+-----------
89 benjamin | Superuser, Cannot login | {}
90 dunder_mifflin_admin | | {}
91 mary | Cannot login | {}
92 postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
93
94
95postgres=# \l
96 List of databases
97 Name | Owner | Encoding | Collate | Ctype | Access privileges
98-----------------+----------+----------+----------------------------+----------------------------+-----------------------
99 food | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
100 pets | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
101 pets2 | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
102 pets3 | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
103 postgres | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
104 restaurants_app | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
105 template0 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres +
106 | | | | | postgres=CTc/postgres
107 template1 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres +
108 | | | | | postgres=CTc/postgres
109(8 rows)
110
111
112postgres=# \dt
113Did not find any relations.
114postgres=# \q
115
116shihc@DESKTOP-29R83UR MINGW64 /
117$ psql -U postgres restaurants_app
118psql (11.2)
119WARNING: Console code page (437) differs from Windows code page (1252)
120 8-bit characters might not work correctly. See psql reference
121 page "Notes for Windows users" for details.
122Type "help" for help.
123
124restaurants_app=# \dt
125 List of relations
126 Schema | Name | Type | Owner
127--------+-------------+-------+----------
128 public | grades | table | postgres
129 public | restaurants | table | postgres
130(2 rows)
131
132
133restaurants_app=# \q
134
135shihc@DESKTOP-29R83UR MINGW64 /
136$ psql
137psql (11.2)
138WARNING: Console code page (437) differs from Windows code page (1252)
139 8-bit characters might not work correctly. See psql reference
140 page "Notes for Windows users" for details.
141Type "help" for help.
142
143postgres=# restaurants_app
144postgres-# \q
145
146shihc@DESKTOP-29R83UR MINGW64 /
147$ psql -U postgres restaurants_app
148psql (11.2)
149WARNING: Console code page (437) differs from Windows code page (1252)
150 8-bit characters might not work correctly. See psql reference
151 page "Notes for Windows users" for details.
152Type "help" for help.
153
154restaurants_app=# \dt
155 List of relations
156 Schema | Name | Type | Owner
157--------+-------------+-------+----------
158 public | grades | table | postgres
159 public | restaurants | table | postgres
160(2 rows)
161
162
163restaurants_app=# \dt restaurants
164 List of relations
165 Schema | Name | Type | Owner
166--------+-------------+-------+----------
167 public | restaurants | table | postgres
168(1 row)
169
170
171restaurants_app=# restaurants
172restaurants_app-# ;
173ERROR: syntax error at or near "restaurants"
174LINE 1: restaurants
175 ^
176restaurants_app=# \dt
177 List of relations
178 Schema | Name | Type | Owner
179--------+-------------+-------+----------
180 public | grades | table | postgres
181 public | restaurants | table | postgres
182(2 rows)
183
184
185restaurants_app=# SELECT NAME restaurants
186restaurants_app-# ;
187ERROR: column "name" does not exist
188LINE 1: SELECT NAME restaurants
189 ^
190restaurants_app=# SELECT NAME restaurants;
191ERROR: column "name" does not exist
192LINE 1: SELECT NAME restaurants;
193 ^
194restaurants_app=# SELECT restaurants;
195ERROR: column "restaurants" does not exist
196LINE 1: SELECT restaurants;
197 ^
198restaurants_app=# SELECT Name FROM restaurants;
199 name
200----------------------------------------------------------------------------------------------------
201 Dj Reynolds Pub And Restaurant
202 Riviera Caterer
203 Morris Park Bake Shop
204 Wendy'S
205 Tov Kosher Kitchen
206 Kosher Island
207 Brunos On The Boulevard
208 Wilken'S Fine Food
209 Taste The Tropics Ice Cream
210 Regina Caterers
211 May May Kitchen
212 Seuda Foods
213 C & C Catering Service
214 1 East 66Th Street Kitchen
215 Laquana King
216 Carvel Ice Cream
217 Carvel Ice Cream
218 Nordic Delicacies
219 Wild Asia
220 Glorious Food
221 The Movable Feast
222 Sal'S Deli
223 Bully'S Deli
224 Steve Chu'S Deli & Grocery
225 White Castle
226 Harriet'S Kitchen
227 P & S Deli Grocery
228 Angelika Film Center
229 The Country Cafe
230 Shashemene Int'L Restaura
231 Ho Mei Restaurant
232 Downtown Deli
233 Carvel Ice Cream
234 Olive'S
235 Dunkin' Donuts
236 Cafe Metro
237 Happy Garden
238 Tony'S Deli
239 Lexler Deli
240 Bagels N Buns
241 Hot Bagels
242 Snack Time Grill
243 Lorenzo & Maria'S
244 Mejlander & Mulgannon
245 Berkely
246 Domino'S Pizza
247 Carvel Ice Cream
248 Sonny'S Heros
249 Domino'S Pizza
250 Golden Pavillion
251 Spoon Bread Catering
252 Kosher Bagel Hole
253 Terminal Cafe/Yankee Clipper
254 Plaza Bagels & Deli
255 Happy Garden
256 B & M Hot Bagel & Grocery
257 Peter Luger Steakhouse
258 Philadelhia Grille Express
259 Metropolitan Club
260 Palm Restaurant
261 Manhem Club
262 21 Club
263 Texas Rotisserie
264 Isle Of Capri Resturant
265 Old Town Bar & Restaurant
266 Polish National Home
267 Seville Restaurant
268 Zoe Place
269 Nyac Main Dining Room
270 7B Bar
271^Crestaurants_app=# \dt
272 List of relations
273 Schema | Name | Type | Owner
274--------+-------------+-------+----------
275 public | grades | table | postgres
276 public | restaurants | table | postgres
277(2 rows)
278
279
280restaurants_app=# SELECT name, borough, cuisine, address_building_number, address_street, address_zipcode, id FROM restaurants
281restaurants_app-# ;
282 name | borough | cuisine
283
284----------------------------------------------------------------------------------------------------+---------------+-----------------------------------------------------------
285---
286 Dj Reynolds Pub And Restaurant | Manhattan | Irish
287 1
288 Riviera Caterer | Brooklyn | American
289 2
290 Morris Park Bake Shop | Bronx | Bakery
291 3
292 Wendy'S | Brooklyn | Hamburgers
293 4
294 Tov Kosher Kitchen | Queens | Jewish/Kosher
295 5
296 Kosher Island | Staten Island | Jewish/Kosher
297 6
298 Brunos On The Boulevard | Queens | American
299 7
300 Wilken'S Fine Food | Brooklyn | Delicatessen
301 8
302 Taste The Tropics Ice Cream | Brooklyn | Ice Cream, Gelato, Yogurt, Ices
303 9
304^Crestaurants_app=# CREATE TABLE(
305restaurants_app(# ^^
306restaurants_app(# ;
307restaurants_app(#
308restaurants_app(# \q
309
310shihc@DESKTOP-29R83UR MINGW64 /
311$ psql -U postgres restaurants_app
312psql (11.2)
313WARNING: Console code page (437) differs from Windows code page (1252)
314 8-bit characters might not work correctly. See psql reference
315 page "Notes for Windows users" for details.
316Type "help" for help.
317
318restaurants_app=# ljdslfkjsdfsdfsdfsdfadfad
319restaurants_app-# ;
320ERROR: syntax error at or near "ljdslfkjsdfsdfsdfsdfadfad"
321LINE 1: ljdslfkjsdfsdfsdfsdfadfad
322 ^
323restaurants_app=# SELECT * FROM restaurants LIMIT 10;
324 id | name | nyc_restaurant_id | borough | cuisine | address_building_number | address_street | address_zipcode
325----+--------------------------------+-------------------+---------------+---------------------------------+-------------------------+-------------------+-----------------
326 1 | Dj Reynolds Pub And Restaurant | 30191841 | Manhattan | Irish | 351 | West 57 Street | 10019
327 2 | Riviera Caterer | 40356018 | Brooklyn | American | 2780 | Stillwell Avenue | 11224
328 3 | Morris Park Bake Shop | 30075445 | Bronx | Bakery | 1007 | Morris Park Ave | 10462
329 4 | Wendy'S | 30112340 | Brooklyn | Hamburgers | 469 | Flatbush Avenue | 11225
330 5 | Tov Kosher Kitchen | 40356068 | Queens | Jewish/Kosher | 97-22 | 63 Road | 11374
331 6 | Kosher Island | 40356442 | Staten Island | Jewish/Kosher | 2206 | Victory Boulevard | 10314
332 7 | Brunos On The Boulevard | 40356151 | Queens | American | 8825 | Astoria Boulevard | 11369
333 8 | Wilken'S Fine Food | 40356483 | Brooklyn | Delicatessen | 7114 | Avenue U | 11234
334 9 | Taste The Tropics Ice Cream | 40356731 | Brooklyn | Ice Cream, Gelato, Yogurt, Ices | 1839 | Nostrand Avenue | 11226
335 10 | Regina Caterers | 40356649 | Brooklyn | American | 6409 | 11 Avenue | 11219
336(10 rows)
337
338
339restaurants_app=# SELECT * FROM restaurants WHERE cuisine = italian;
340ERROR: column "italian" does not exist
341LINE 1: SELECT * FROM restaurants WHERE cuisine = italian;
342 ^
343restaurants_app=# ;
344restaurants_app=# SELECT * FROM restaurants WHERE cuisine = Italisn;
345ERROR: column "italisn" does not exist
346LINE 1: SELECT * FROM restaurants WHERE cuisine = Italisn;
347 ^
348restaurants_app=# SELECT * FROM restaurants WHERE cuisine = Italian;
349ERROR: column "italian" does not exist
350LINE 1: SELECT * FROM restaurants WHERE cuisine = Italian;
351 ^
352restaurants_app=# SELECT * FROM restaurants WHERE cuisine = 'Italian';
353 id | name | nyc_restaurant_id | borough | cuisine | address_building_number | address_street | address_zipc
354ode
355-------+----------------------------------------------------+-------------------+---------------+---------+-------------------------+-----------------------------+-------------
356----
357 58 | Philadelhia Grille Express | 40364305 | Brooklyn | Italian | 10004 | 4 Avenue | 11209
358 64 | Isle Of Capri Resturant | 40364373 | Manhattan | Italian | 1028 | 3 Avenue | 10065
359 79 | Marchis Restaurant | 40364668 | Manhattan | Italian | 251 | East 31 Street | 10016
360 109 | Arturo'S | 40365387 | Manhattan | Italian | 106 | West Houston Street | 10012
361 127 | Parkside Restaurant | 40365841 | Queens | Italian | 10701 | Corona Avenue | 11368
362 146 | Nanni Restaurant | 40366157 | Manhattan | Italian | 146 | East 46 Street | 10017
363 220 | Roadhouse Restaurant | 40368034 | Staten Island | Italian | 1402 | Clove Road | 10301
364 338 | Aunt Bella'S Rest Of Little Neck | 40371807 | Queens | Italian | 4619 | Marathon Parkway | 11362
365 418 | Villa Fiorita | 40375929 | Brooklyn | Italian | 7720 | 18 Avenue | 11214
366 546 | Cha Cha'S Backyard Garden Bar & Cafe | 40383009 | Manhattan | Italian | 113 | Mulberry Street | 10013
367 645 | Arno Ristorante | 40386747 | Manhattan | Italian | 141 | West 38 Street | 10018
368 654 | Da Umberto Restaurant | 40387162 | Manhattan | Italian | 107 | West 17 Street | 10011
369 673 | Tre Giovani Pizza & Pasta | 40387890 | Manhattan | Italian | 548 | La Guardia Place | 10012
370 683 | Venice Restaurant | 40387477 | Bronx | Italian | 772 | East 149 Street | 10455
371 711 | Sette Mezzo | 40388787 | Manhattan | Italian | 969 | Lexington Avenue | 10021
372 738 | Rino'S | 40389594 | Bronx | Italian | 3938 | East Tremont Avenue | 10465
373 747 | Queen | 40389903 | Brooklyn | Italian | 84 | Court Street | 11201
374 774 | Cafe Luna | 40390850 | Staten Island | Italian | 1300 | Hylan Boulevard | 10305
375 119 | V & T Restaurant | 40365577 | Manhattan | Italian | 1024 | Amsterdam Avenue | 10025
376 128 | Barbetta Restaurant | 40365726 | Manhattan | Italian | 319321 | 323 W. 46Th St. | 10036
377 312 | Cucina Vivolo | 40370497 | Manhattan | Italian | 138140 | East 74 Street | 10021
378 348 | Marina Cafe | 40372357 | Staten Island | Italian | 154 | Mansion Ave | 10308
379 401 | Casa Bella | 40374834 | Manhattan | Italian | 127 | Mulberry Street | 10013
380 461 | Red Rose | 40378328 | Brooklyn | Italian | 315 | Smith Street | 11231
381 489 | Mezzaluna | 40379662 | Manhattan | Italian | 1295 | Third Avenue | 10021
382 615 | Primola Restaurant | 40386001 | Manhattan | Italian | 1226 | Second Avenue | 10065
383 682 | Scaletta Ristorante | 40388214 | Manhattan | Italian | 50 | West 77 Street | 10024
384 825 | La Strada Restaurant | 40391857 | Staten Island | Italian | 139 | New Dorp Lane | 10306
385 893 | Manetta'S Ristorante | 40393985 | Queens | Italian | 1076 | Jackson Avenue | 11101
386 93 | Forlinis Restaurant | 40365098 | Manhattan | Italian | 93 | Baxter Street | 10013
387 102 | Angelo Of Mulberry St. | 40365293 | Manhattan | Italian | 146 | Mulberry Street | 10013
388 212 | Fiorellos | 40367841 | Manhattan | Italian | 1900 | Broadway | 10023
389 231 | Da Silvano Restaurant | 40368346 | Manhattan | Italian | 260 | 6 Avenue | 10014
390 285 | Ferdinando'S Restaurant | 40369716 | Brooklyn | Italian | 151 | Union Street | 11231
391 349 | Don Filippo Restaurant | 40372417 | Manhattan | Italian | 1133 | Lexington Avenue | 10075
392 358 | Clinton Restaurant | 40372694 | Queens | Italian | 917 | Clintonville Street | 11357
393 402 | Bar Vetro | 40374559 | Manhattan | Italian | 222 | East 58 Street | 10022
394 412 | Arturo'S | 40375616 | Manhattan | Italian | 1617 | York Avenue | 10028
395 523 | Uno Chicago Grill | 40381896 | Queens | Italian | 107-16 | 70 Road | 11375
396 550 | Sistina Restaurant | 40383262 | Manhattan | Italian | 1555 | 2 Avenue | 10028
397 559 | Canlon'S Restaurant | 40383737 | Staten Island | Italian | 1825 | North Railroad Avenue | 10306
398 705 | Spoto'S Restaurant | 40388462 | Bronx | Italian | 4005 | East Tremont Avenue | 10465
399 760 | Papazzio Restaurant | 40390241 | Queens | Italian | 3938 | Bell Boulevard | 11361
400 103 | New Corner | 40365355 | Brooklyn | Italian | 7201 | 8 Avenue | 11228
401 195 | John'S Restaurant | 40367407 | Manhattan | Italian | 302 | East 12 Street | 10003
402 376 | Il Mulino | 40373888 | Manhattan | Italian | 86 | West 3 Street | 10012
403^Crestaurants_app=# SELECT id, name FROM restaurants WHERE cuisine = 'Italian' LIMIT 10;
404 id | name
405-----+--------------------------------------
406 58 | Philadelhia Grille Express
407 64 | Isle Of Capri Resturant
408 79 | Marchis Restaurant
409 109 | Arturo'S
410 127 | Parkside Restaurant
411 146 | Nanni Restaurant
412 220 | Roadhouse Restaurant
413 338 | Aunt Bella'S Rest Of Little Neck
414 418 | Villa Fiorita
415 546 | Cha Cha'S Backyard Garden Bar & Cafe
416(10 rows)
417
418
419restaurants_app=# SELECT COUNT(*) FROM restaurants WHERE cuisine = 'Thai';
420 count
421-------
422 285
423(1 row)
424
425
426restaurants_app=# SELECT COUNT(*) FROM restaurants;
427 count
428-------
429 25359
430(1 row)
431
432
433restaurants_app=# SELECT COUNT(*) FROM restaurants WHERE cuisine = 'Thai
434restaurants_app'# WHERE address_zipcode = '11372';
435restaurants_app'#
436restaurants_app'#
437restaurants_app'#
438restaurants_app'#
439restaurants_app'#
440restaurants_app'#
441restaurants_app'#
442restaurants_app'#
443restaurants_app'#
444restaurants_app'#
445restaurants_app'# ;
446restaurants_app'# \q
447Use control-C to quit.
448restaurants_app'# \q
449Use control-C to quit.
450restaurants_app'# =
451restaurants_app'# ===========
452restaurants_app'# ;
453restaurants_app'# ;
454restaurants_app'# --help
455restaurants_app'# '
456restaurants_app-# ;
457ERROR: syntax error at or near "11372"
458LINE 2: WHERE address_zipcode = '11372';
459 ^
460restaurants_app=# SELECT COUNT(*) FROM restaurants WHERE cuisine = 'Thai' WHERE address_zipcode = '11372';
461ERROR: syntax error at or near "WHERE"
462LINE 1: ... COUNT(*) FROM restaurants WHERE cuisine = 'Thai' WHERE addr...
463 ^
464restaurants_app=# SELECT COUNT(*) FROM restaurants WHERE cuisine = 'Thai' AND address_zipcode = '11372';
465 count
466-------
467 5
468(1 row)
469
470
471restaurants_app=# SELECT id, name FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR address_zipcode = '10013' OR address_zipcode = '10014' ORDER BY na
472me LIMIT 5;
473 id | name
474-------+-----------------------------
475 25047 |
476 24962 |
477 8751 | / L'Ecole
478 24324 | 002 Mercury Tacos Llc
479 15516 | 102 Noodles Town Restaurant
480(5 rows)
481
482
483restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHEREcuisine = 'Italian' AND address_zipcode = '10012' OR address_zipcode = '10013' OR address_zipc
484ode = '10014' ORDER BY na
485restaurants_app-# me LIMIT 5;
486ERROR: syntax error at or near "="
487LINE 1: ...ne, address_zipcode FROM restaurants WHEREcuisine = 'Italian...
488 ^
489restaurants_app=# SELECT id, name FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR address_zipcode = '10013' OR address_zipcode = '10014' ORDER BY na
490
491restaurants_app-# me LIMIT 5;
492ERROR: syntax error at or near "me"
493LINE 2: me LIMIT 5;
494 ^
495restaurants_app=# SELECT id, name FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR address_zipcode = '10013' OR address_zipcode = '10014' ORDER BY na
496
497restaurants_app-# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR address_zipcode = '10013' OR address_zip
498code = '10014' ORDER BY name LIMIT 5;
499ERROR: syntax error at or near "SELECT"
500LINE 2: SELECT id, name, cuisine, address_zipcode FROM restaurants W...
501 ^
502restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR address_zipcode = '10013' OR address_zip
503code = '10014' ORDER BY name LIMIT 5;
504 id | name | cuisine | address_zipcode
505-------+-----------------------------+---------+-----------------
506 25047 | | Other | 10014
507 24962 | | Other | 10013
508 8751 | / L'Ecole | French | 10013
509 24324 | 002 Mercury Tacos Llc | Other | 10014
510 15516 | 102 Noodles Town Restaurant | Chinese | 10013
511(5 rows)
512
513
514restaurants_app=# SELECT id, name, cuisine FROM restaurants WHERE cuisine = 'Italian' ORDER BY name LIMIT 5;
515 id | name | cuisine
516-------+----------------------------------------+---------
517 3219 | (Lewis Drug Store) Locanda Vini E Olii | Italian
518 1823 | 101 Restaurant And Bar | Italian
519 2618 | 44 Sw Ristorante & Bar | Italian
520 17862 | 900 Park | Italian
521 18146 | A-Roma Bakery | Italian
522(5 rows)
523
524
525restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' ORDER BY name LIMIT 5;
526 id | name | cuisine | address_zipcode
527-------+----------------------+---------+-----------------
528 109 | Arturo'S | Italian | 10012
529 2023 | Ballato'S Restaurant | Italian | 10012
530 13394 | Bella Donna Cafe | Italian | 10012
531 20538 | Bianca | Italian | 10012
532 3378 | Bread | Italian | 10012
533(5 rows)
534
535
536restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' AND address_zipcode = '10013' ORDER BY name
537 LIMIT 5;
538 id | name | cuisine | address_zipcode
539----+------+---------+-----------------
540(0 rows)
541
542
543restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR address_zipcode = '10013' ORDER BY name
544LIMIT 5;
545 id | name | cuisine | address_zipcode
546-------+-----------------------------+---------+-----------------
547 24962 | | Other | 10013
548 8751 | / L'Ecole | French | 10013
549 15516 | 102 Noodles Town Restaurant | Chinese | 10013
550 24976 | 12 Corners Coffee Inc | Other | 10013
551 11957 | 218 Restaurant | Chinese | 10013
552(5 rows)
553
554
555restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012', '10013', '10014' ORDER BY name LIMIT 5;
556ERROR: syntax error at or near ","
557LINE 1: ... cuisine = 'Italian' AND address_zipcode = '10012', '10013',...
558 ^
559restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR cuisine = 'Italian' AND address_zipcode
560= '10013' ORDER BY name LIMIT 5;
561 id | name | cuisine | address_zipcode
562-------+------------------------+---------+-----------------
563 1149 | Acappella Restaurant | Italian | 10013
564 14050 | Amici Ii | Italian | 10013
565 102 | Angelo Of Mulberry St. | Italian | 10013
566 109 | Arturo'S | Italian | 10012
567 7139 | Aurora Soho | Italian | 10013
568(5 rows)
569
570
571restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR cuisine = 'Italian' AND address_zipcode
572= '10013' AND cuisine = 'Italian ORDER BY name LIMIT 5;
573restaurants_app'# '
574restaurants_app-# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR cuisine = 'Italian' AND address_zipcode
575= '10013' OR cuisine = 'Italian' AND address_zipcode = '10014' ORDER BY name LIMIT 5;
576ERROR: syntax error at or near "SELECT"
577LINE 3: SELECT id, name, cuisine, address_zipcode FROM restaurants W...
578 ^
579restaurants_app=# ;
580restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND address_zipcode = '10012' OR cuisine = 'Italian' AND address_zipcode
581= '10013' OR cuisine = 'Italian' AND address_zipcode = '10014' ORDER BY name LIMIT 5;
582 id | name | cuisine | address_zipcode
583-------+------------------------+---------+-----------------
584 9442 | Abottega | Italian | 10014
585 1149 | Acappella Restaurant | Italian | 10013
586 14050 | Amici Ii | Italian | 10013
587 11613 | Anfora | Italian | 10014
588 102 | Angelo Of Mulberry St. | Italian | 10013
589(5 rows)
590
591
592restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND WHERE (address_zipcode = '10012' AND address_zipcode = '10013' AND ad
593dress_zipcode = '10014') ORDER BY name LIMIT 5;
594ERROR: syntax error at or near "WHERE"
595LINE 1: ...de FROM restaurants WHERE cuisine = 'Italian' AND WHERE (add...
596 ^
597restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND (address_zipcode = '10012' AND address_zipcode = '10013' AND address_
598zipcode = '10014') ORDER BY name LIMIT 5;
599 id | name | cuisine | address_zipcode
600----+------+---------+-----------------
601(0 rows)
602
603
604restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' WHERE (address_zipcode = '10012' AND address_zipcode = '10013' AND addres
605s_zipcode = '10014') ORDER BY name LIMIT 5;
606ERROR: syntax error at or near "WHERE"
607LINE 1: ...ipcode FROM restaurants WHERE cuisine = 'Italian' WHERE (add...
608 ^
609restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND (address_zipcode = '10012' OR address_zipcode = '10013' OR address_zi
610pcode = '10014') ORDER BY name LIMIT 5;
611 id | name | cuisine | address_zipcode
612-------+------------------------+---------+-----------------
613 9442 | Abottega | Italian | 10014
614 1149 | Acappella Restaurant | Italian | 10013
615 14050 | Amici Ii | Italian | 10013
616 11613 | Anfora | Italian | 10014
617 102 | Angelo Of Mulberry St. | Italian | 10013
618(5 rows)
619
620
621restaurants_app=# SELECT id, name, cuisine, address_zipcode FROM restaurants WHERE cuisine = 'Italian' AND (address_zipcode = '10012' OR '10013' OR '10014') ORDER BY name LIMIT
622 5;
623ERROR: invalid input syntax for type boolean: "10013"
624LINE 1: ...ine = 'Italian' AND (address_zipcode = '10012' OR '10013' OR...
625 ^
626restaurants_app=# INSERT INTO restaurants (name, borough, cuisine, address_building_number, address_street, address_zipcode) VALUES ('Byte Cafe', 'Brooklyn', 'coffee', '123', '
627Atlantic Avenue', '11231');
628INSERT 0 1
629restaurants_app=# SELECT name FROM restaurants WHERE cuisine = 'coffee' AND address_zipcode = '11231';
630 name
631-----------
632 Byte Cafe
633(1 row)
634
635
636restaurants_app=# SELECT * FROM restaurants WHERE cuisine = 'coffee' AND address_zipcode = '11231';
637 id | name | nyc_restaurant_id | borough | cuisine | address_building_number | address_street | address_zipcode
638-------+-----------+-------------------+----------+---------+-------------------------+-----------------+-----------------
639 25360 | Byte Cafe | | Brooklyn | coffee | 123 | Atlantic Avenue | 11231
640(1 row)
641
642
643restaurants_app=# INSERT INTO restaurants (name, borough, cuisine, address_building_number, address_street, address_zipcode) VALUES ('Pasta', 'Poop', 'Chinese', '123', 'A Stree
644t', '12345'), ('Ryans Radishes', 'Z', 'Artisanal Radishes', '1', 'Radish Loop', '12345'), ('Food House', 'No', 'Food', '6969', '420 Street', '12345');
645ERROR: invalid input value for enum borough_options: "Poop"
646LINE 1: ...address_street, address_zipcode) VALUES ('Pasta', 'Poop', 'C...
647 ^
648restaurants_app=# INSERT INTO restaurants (name, borough, cuisine, address_building_number, address_street, address_zipcode) VALUES ('Pasta', 'Queens', 'Chinese', '123', 'A Str
649eet', '12345'), ('Ryans Radishes', 'Brooklyn', 'Artisanal Radishes', '1', 'Radish Loop', '12345'), ('Food House', 'Brooklyn', 'Food', '6969', '420 Street', '12345');
650INSERT 0 3
651restaurants_app=# SELECT * FROM restaurants WHERE address_zipcode = '12345';
652 id | name | nyc_restaurant_id | borough | cuisine | address_building_number | address_street | address_zipcode
653-------+----------------+-------------------+----------+--------------------+-------------------------+----------------+-----------------
654 25361 | Pasta | | Queens | Chinese | 123 | A Street | 12345
655 25362 | Ryans Radishes | | Brooklyn | Artisanal Radishes | 1 | Radish Loop | 12345
656 25363 | Food House | | Brooklyn | Food | 6969 | 420 Street | 12345
657(3 rows)
658
659
660restaurants_app=# UPDATE restaurants SET name = 'DJ Reynolds Pub and Restaurant' WHERE nyc_restaurant_id = '30191841';
661UPDATE 1
662restaurants_app=# SELECT * FROM restaurants WHERE nyc_restaurant_id = '30191841';
663 id | name | nyc_restaurant_id | borough | cuisine | address_building_number | address_street | address_zipcode
664----+--------------------------------+-------------------+-----------+---------+-------------------------+------------------+-----------------
665 1 | DJ Reynolds Pub and Restaurant | 30191841 | Manhattan | Irish | 351 | West 57 Street | 10019
666(1 row)
667
668
669restaurants_app=# SELECT * FROM grades WHERE id = 10;
670 id | date | grade | score | restaurant_id
671----+------------------------+-------+-------+---------------
672 10 | 2013-09-11 00:00:00+00 | A | 6 | 3
673(1 row)
674
675
676restaurants_app=# DELETE FROM grades WHERE id = 10;
677DELETE 1
678restaurants_app=# SELECT * FROM grades WHERE id = 10;
679 id | date | grade | score | restaurant_id
680----+------+-------+-------+---------------
681(0 rows)
682
683
684restaurants_app=# DELETE FROM restaurants WHERE id = 22;
685ERROR: update or delete on table "restaurants" violates foreign key constraint "grades_restaurant_id_fkey" on table "grades"
686DETAIL: Key (id)=(22) is still referenced from table "grades".
687restaurants_app=# CREATE TABLE inspectors(id serial PRIMARY KEY, first_name text NOT NULL, last_name text NOT NULL, borough borough_options);
688CREATE TABLE
689restaurants_app=# SELECT * FROM inspectors
690restaurants_app-# ;
691 id | first_name | last_name | borough
692----+------------+-----------+---------
693(0 rows)
694
695
696restaurants_app=# ALTER TABLE grades ADD notes text;
697ALTER TABLE
698restaurants_app=# SELECT * FROM grades LIMIT 3;
699 id | date | grade | score | restaurant_id | notes
700----+------------------------+-------+-------+---------------+-------
701 1 | 2014-09-06 00:00:00+00 | A | 2 | 1 |
702 2 | 2014-06-10 00:00:00+00 | A | 5 | 2 |
703 3 | 2013-07-22 00:00:00+00 | A | 11 | 1 |
704(3 rows)
705
706
707restaurants_app=# \dt
708 List of relations
709 Schema | Name | Type | Owner
710--------+-------------+-------+----------
711 public | grades | table | postgres
712 public | inspectors | table | postgres
713 public | restaurants | table | postgres
714(3 rows)
715
716
717restaurants_app=# DROP TABLE reviews;
718ERROR: table "reviews" does not exist
719restaurants_app=# DROP TABLE IF EXISTS reviews;
720NOTICE: table "reviews" does not exist, skipping
721DROP TABLE
722restaurants_app=# DROP TABLE inspectors;
723DROP TABLE
724restaurants_app=# \dt
725 List of relations
726 Schema | Name | Type | Owner
727--------+-------------+-------+----------
728 public | grades | table | postgres
729 public | restaurants | table | postgres
730(2 rows)
731
732
733restaurants_app=#