Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-h' which is for host, not database name.
Using '-U' which is for username, not database name.
✗ Incorrect
The -d option specifies the database name to connect to in psql.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-W' which prompts for password, not username.
Using '-p' which is for port number.
✗ Incorrect
The -U option specifies the username to connect as in psql.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-U' which is for username, not host.
Using '-d' again which is for database name.
✗ Incorrect
The -h option specifies the host to connect to in psql.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-U' instead of '-d' for database name.
Using '-h' instead of '-f' for file.
✗ Incorrect
Use -d to specify the database and -f to specify the SQL file to run.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up '-U' and '-h' options.
Using '-p' for host instead of port.
✗ Incorrect
Use -d for database, -U for user, and -h for host in psql.