Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to change the ownership of a existing table in hive

Highlighted

How to change the ownership of a existing table in hive

Contributor

Hi Team,

I have a table called 'test' and its owner is 'ben', I need to change the ownership of the same table from 'ben' to 'sam' and i don't have login access to sam.

How can i achieve this , Is there any possibility to change the ownership or is there any command to change the ownership

Regards,

Mathivanan

3 REPLIES 3
Highlighted

Re: How to change the ownership of a existing table in hive

Hey @Mathi Murugan!
Hm, could you share with us more details? Is your environment secure (kerberos, ranger, knox, hdfs acl)?
If it isn't, then try to add permission to your user through chmod (to have write/read permissions) or take the ownership through chown, would be smtg like this:

hdfs dfs -chmod - R 777 /apps/hive/warehouse/salaries --TABLE SALARIES
hdfs dfs -chown -R hive:hadoop /apps/hive/warehouse/salaries --Changing the ownership from root to hive
Just remember that you'll need to run these commands as hdfs user or have the same permission as hdfs.

Hope this helps!

Highlighted

Re: How to change the ownership of a existing table in hive

New Contributor

Hdfs chown command would be ok, but Hive meta also maintains owner information such as tbls.owner in mysql. I think it is better to use Hive command if provided.

Highlighted

Re: How to change the ownership of a existing table in hive

Mentor

@Mathi Murugan

I see that currently ALTER (DATABASE|SCHEMA) database_name SET OWNER [USER|ROLE] user_or_role; does not give the desired fine-grained option for only a specific table in a schema/database, so I think the best option would be to use Ranger and give a select privilege on the particular database or underlying table to the new user who can then issue a Create Table As Select (CTAS) which will automatically change the ownership to the issuer of the CTAS.

HTH

Don't have an account?
Coming from Hortonworks? Activate your account here