Reputation: 482
Does CockroachDB let me change the table owner? I can’t find something that’s equivalent to Postgres’ REASSIGN OWNED
command. I ultimately want to control which user has access to modify the table.
Upvotes: 1
Views: 544
Reputation: 41
change the owner of a table with
ALTER TABLE <name> OWNER TO <newowner>
see https://www.cockroachlabs.com/docs/v20.2/owner-to.html
Upvotes: 0
Reputation: 482
CockroachDB doesn't have the same notion of “table owners” that Postgres does. All tables are “owned” by root
by default, but you can control access that other users have through GRANT
.
First you’ll need to create a new user:
cockroach user set johndoe;
Now, log in to the Cockroach SQL shell and grant johndoe
the permissions you want (you can find a list of permissions in the documentation:
cockroach sql
GRANT ALL ON db TO johndoe;
After that you can quit the SQL shell (ctrl + C
) and then access the shell again as the new user:
cockroach sql --user=johndoe
Upvotes: 1