Create DB2 User & Grant View Permissions

To create a user and grant viewing permissions in DB2, you can follow these steps:

  1. First, log in to the DB2 database with administrator privileges.
  2. To create a new user, you can use the following SQL statement:
CREATE USER new_user IDENTIFIED BY password;

This will create a new user named new_user, and set the password as password.

  1. Grant the user view permissions by using the following SQL statement:
GRANT SELECT ON <schema_name>.<table_name> TO new_user;

Replace and with the schema and name of the table you want to grant permissions to. If you want to grant a user permission to view across the entire database, you can use the following SQL statement:

GRANT SELECT ON DATABASE TO new_user;
  1. Finally, use the following SQL statement to refresh permissions for the changes to take effect:
FLUSH PRIVILEGES;

By following the steps above, you have successfully created a new user and granted them viewing permissions. Your user can now access the specified tables or the entire database.

bannerAds