Create DB2 User & Grant View Permissions
To create a user and grant viewing permissions in DB2, you can follow these steps:
- First, log in to the DB2 database with administrator privileges.
- 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.
- Grant the user view permissions by using the following SQL statement:
GRANT SELECT ON <schema_name>.<table_name> TO new_user;
Replace
GRANT SELECT ON DATABASE TO new_user;
- 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.