Re:PostgreSQL Schema Design
by uhoh-itsmaciek on Sunday March 29, 2020 @04:25PM
(#22722383)
You got some good answers already, but one thing to note is that a Postgres connection is always to a single database. So you can query across multiple schemas from the same connection, but not multiple databases.
[ Parent
| on HN ]
Re:PostgreSQL Schema Design
by quietbritishjim on Sunday March 29, 2020 @06:46PM
(#22723488)
Indeed, this means that it is logically impossible to connect to postgres and create a database, at least through a normal connection. But you can create a schema with the CREATE SCHEMA statement.
Re:PostgreSQL Schema Design
by uhoh-itsmaciek on Sunday March 29, 2020 @07:18PM
(#22723651)
You can create databases via sql [1]. It's just that after you run the statement, you're still connected to the old database and you need to disconnect in order to connect to the new one.
[1]: https://www.postgresql.org/docs/current/sql-createdatabase.h...
Re:PostgreSQL Schema Design
by quietbritishjim on Monday March 30, 2020 @12:56PM
(#22729712)
Wow, I had no idea. Thank you so much!
(A few lost internet points from the downvotes are well worth it for that gem of knowledge.)