Lesson 2of 3
PostgreSQL Practice Exercises
Practice PostgreSQL user creation and permission management by creating a trainee role, granting database access, testing table permissions, and using GRANT and REVOKE in a realistic lab exercise.
Problem Statement 1: PostgreSQL User Creation and Permission Management
A database administrator wants to provide a new trainee, named trainee, with controlled access to the PostgreSQL dvdrental database.
The administrator must create a new database user, allow the user to connect to the database, and test the user's permissions. Initially, the trainee should not have permission to read data from the film table. The administrator will then grant SELECT permission on that table and verify that the trainee can retrieve records successfully.
Tasks
- Connect to PostgreSQL using the administrator account.
- Create a new user named
traineewith a password. - Grant the user permission to connect to the
dvdrentaldatabase. - Log in to the database using the
traineeaccount. - Test access to the
filmtable before grantingSELECTpermission. - Grant
SELECTpermission on thefilmtable totrainee. - Log in again as
traineeand retrieve the first 10 film records. - Verify the current database user and explain the difference between database connection permission and table access permission.