0
0
PostgreSQLquery~10 mins

psql command-line tool basics in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to connect to a PostgreSQL database named 'school' using psql.

PostgreSQL
psql [1] school
Drag options to blanks, or click blank then click option'
A-U
B-h
C-d
D-p
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-h' which is for host, not database name.
Using '-U' which is for username, not database name.
2fill in blank
medium

Complete the command to connect to the database 'library' as user 'admin' using psql.

PostgreSQL
psql -d library [1] admin
Drag options to blanks, or click blank then click option'
A-U
B-h
C-p
D-W
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-W' which prompts for password, not username.
Using '-p' which is for port number.
3fill in blank
hard

Fix the error in the command to connect to host 'localhost' on port 5432 using psql.

PostgreSQL
psql -d mydb [1] localhost -p 5432
Drag options to blanks, or click blank then click option'
A-h
B-U
C-d
D-W
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-U' which is for username, not host.
Using '-d' again which is for database name.
4fill in blank
hard

Fill both blanks to run a SQL file named 'setup.sql' on database 'testdb' using psql.

PostgreSQL
psql [1] testdb [2] setup.sql
Drag options to blanks, or click blank then click option'
A-f
B-d
C-U
D-h
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-U' instead of '-d' for database name.
Using '-h' instead of '-f' for file.
5fill in blank
hard

Fill all three blanks to connect to database 'shop', user 'alice', host 'db.example.com' using psql.

PostgreSQL
psql [1] shop [2] alice [3] db.example.com
Drag options to blanks, or click blank then click option'
A-d
B-U
C-h
D-p
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up '-U' and '-h' options.
Using '-p' for host instead of port.