Commands to change name, schema, owner

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Commands to change name, schema, owner
Date: 2003-06-20 18:00:14
Message-ID: Pine.LNX.4.44.0306201932560.2297-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

We only have sporadic support to rename objects, change the owner of
objects, and no support to change the schema of an object. So how about a
big bang to add support for these three operations for every object where
it is applicable? I hope to do it without a separate parse structure and
routine for each kind of object and operation, so it can easily be
extended.

Are there any tricky problems with any of these operations? For example,
what happens when an object you have used, say, in a view gets moved to a
schema that you don't have access to. Bad luck?

Renaming is possible for: aggregate, constraint, conversion, database,
domain, function, group, index, language, operator, opclass, rule, schema,
sequence, table, trigger, type, user, view.

The command is: ALTER THING oldname RENAME TO newname;

Requires being the owner of the object (or superuser for group, user,
language) and CREATE privilege on containing schema.

Changing the owner is possible for: aggregate, conversion, database,
domain, function, operator, opclass, schema, sequence, table, type, view.

The command is: ALTER THING name AUTHORIZATION username; (This is
consistent with the CREATE SCHEMA syntax. Anyone like OWNER better?)

Requires being superuser.

Changing the schema is possible for: aggregate, conversion, domain,
function, operator, opclass, table, type, view.

The command is: ALTER THING name SCHEMA newschema;

Requires USAGE on old schema(?), owner of object, CREATE in new schema.

--
Peter Eisentraut peter_e(at)gmx(dot)net

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2003-06-20 18:09:22 Re: src/bin/scripts seems a bit of a misnomer now
Previous Message Jason Earl 2003-06-20 17:44:33 Re: Two weeks to feature freeze