2

I have installed PostgreSQL 13.1 on two computers, a laptop and desktop.

I created database using a Tablespace on a portable SSD drive under F:\MyProject\DB\PG_13_202007201\20350. So I expect all the database files to be in there somewhere.

I want to work on the database on the SSD drive which is fine on the laptop that created the database, but when I go to my desktop I can't figure out how to attach (SQL Server style) the existing database/tablespace and continue working on it.

Is there a way to work like this with Postgresql?

2
  • 1
    You cannot "attach (SQL Server style)" a Postgres database. You'll need to configure your Postgres cluster to look for the database files on the mounted path. See if this helps.
    – mustaccio
    Commented Nov 25, 2020 at 23:39
  • Answered here. Commented Nov 26, 2020 at 4:55

1 Answer 1

3

I suggest you to create a new cluster in your external drive. You can use initdb to create a new PostgreSQL database cluster.

Here is a sample command;

C:\Program Files\PostgreSQL\13\bin\initdb --pgdata="F:\MyProject\pgdata\13\main"

After that you even can register your new cluster as a new postgresql server service by using pg_ctl like the one below;

C:\Program Files\PostgreSQL\13\bin\pg_ctl register --pgdata="F:\MyProject\pgdata\13\main" 
0

Your Answer

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

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