Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to give a postgres database an alias?

Essentially, I need a single database to operate with two names, so that I could make queries to, say, DB_ALPHA and DB_ONE and they'd have the exact same effect. I accomplished this in MySQL by putting a symbolic link to the database in the same directory. I haven't been able to find an equivalent of this solution in postgres.

I appreciate the help! Thanks!

share|improve this question
I've never heard a requirement like this but maybe one of the proxies along the lines of pg_pool can help? – Server Horror Jul 4 '11 at 23:02

You cannot create an alias to a schema or database since the Schemaname / DBname is used internally as primary key for the tables pg_namespace and pg_database.

share|improve this answer

No you can't. In PostgreSQL you have to connect to a single database before you can execute any query. In MySQL you have only one database and many schema's (called "databases" in the MySQL-world), you can always execute a query on a different "database".

If you want the same setup in PostgreSQL, just create different schema's in your database.

share|improve this answer

Do you need write queries as well as read queries? I'd be tempted to try and create the second database, and then use a symbolic link at the database directory level to point to the first databases directory. That might be ok as long as you were sticking to read only queries in the second system; otoh you might get all kinds of corruption from weird shared memory related problems, but it'd be an interesting experiment.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.