Quantcast
Viewing all articles
Browse latest Browse all 145

Managing Users and Permissions on Vertica environment

Like most database management systems, Vertica allows managing security for users in order to make sure each user gets only the permissions that he actually needs.

Here’s a cheat sheet I use for managing the users in organizations I consult to.

    • Get user permissions

SELECT u.user_name,u.all_roles,u.default_roles,g.privileges_description,g.object_name
FROM users u join grants g on u.user_name = g.grantee
WHERE u.user_name like '%UserName%'

    • Create user with password

CREATE USER UserName IDENTIFIED BY 'MyPassword';

    • Change user password

ALTER USER UserName IDENTIFIED BY 'new-password' REPLACE 'old-password';

    • Grant all permissions to a user on a table

GRANT ALL ON TABLE SchemaName.TableName to UserName;

-- Or if you like to grant specific privilege like:
-- INSERT, SELECT, UPDATE, DELETE, REFERENCES
GRANT SELECT ON TABLE SchemaName.TableName to UserName;

    • Grant privilege on all tables

GRANT SELECT ON ALL TABLES IN SchemaName.TableName to UserName;

    • Great all permissions to a user on a SCHEMA

GRANT ALL ON SCHEMA dwh to aolon_app;

-- Or if you want to grant specific a privilege like:
-- CREATE, USAGE
GRANT SELECT ON SCHEMA SchemaName TO UserName;

    • Set user as table owner

ALTER TABLE TableName OWNER TO UserName;

 

 

In addition to managing users, Vertica allow grouping users to roles in order to manage permissions for a group of users. I covered roles extensively here, but here are the parts which are relevant to users:

    • Add user to the Role

GRANT RoleName TO UserName;

    • Remove user from Role

REVOKE RoleName FROM UserName;

    • Add user default role (if you want a user to have a role, you must set him a default role)

ALTER USER UserName DEFAULT ROLE RoleName;

    • Select which Users are in a role

SELECT object_schema,object_name,privileges_description,grantor,grantee 
FROM grants 
WHERE object_name like 'RoleName';

    • Select which roles a user assigned to.

SELECT user_name,all_roles,default_roles
FROM users 
WHERE user_name like 'UserName';

 

Read previous post in Vertica posts series- How to Create and Manage Security Roles in Vertica

The post Managing Users and Permissions on Vertica environment appeared first on .


Viewing all articles
Browse latest Browse all 145

Trending Articles