0

Im trying to alter a table ALTER TABLE database.table...

What is the correct notation to access tables in a DB from the base postgres db without having to explicitly connect to that database?

1
  • 2
    Postgres is not MySQL where a database is actually a schema. A database in Postgres is a separate global object that can only be operated on by connecting to it. If you want to do this in Postgres then emulate MySQL by separating objects into schema's. Commented May 30, 2022 at 0:07

2 Answers 2

1

There is no way. You have to connect to the right database.

Sign up to request clarification or add additional context in comments.

Comments

0

A DATABASE within MySQL is comparable with a SCHEMA in PostgreSQL and many other brands.

MySQL: ALTER TABLE database.table... Others: ALTER TABLE schema.table...

From the MySQL manual:

CREATE SCHEMA is a synonym for CREATE DATABASE.

This actually means that a single MySQL server has just a single database. This database can have many schema's and every schema can have many tables.

Within a single database you can jump from one schema to the other schema, no problem. This works for MySQL, PostgreSQL and many others. You can not jump from one database to another database without a new database connection because it's a different instance.

It is that MySQL uses a different name for a schema, it calls this a database. A little confusing.

If you want the same thing in other databases, like PostgreSQL, just use schema's within a single database.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.