PostgreSQL

PostgreSQL Information

**Note: If you don't have the Utopia solution cloned to your local machine, follow these instructions

Installation and Setup

Connecting to your Server

Creating your Database

Changing the postgres user's password

If you accidentally didn't set the postgres user's password to our standard pass@word1, then here are steps to help you fix it.

  1. Open Command Prompt and navigate to the PostgreSQL bin folder on your machine. Assuming you didn't change the default installation directory, the path should be C:\Program Files\PostgreSQL\13\bin
  2. Once there, you can use the psql command (another way to do this is to add that bin folder path to your environment PATH variable). Type the following command:
    psql -U postgres
  3. You will be asked for the current password of the pstgress user. Enter it to continue.
  4. Type alter user postgres with password 'pass@word1', and you can substitute pass@word1 with any password you happen to need.
  5. The command \q exits you back to the regular command line. Yay, your postgres user password will now be what you want!

Distribute Foreign Keys

When it's time to distribute the foreign keys in postgres:
select 'alter table '||quote_ident(ns.nspname)||'.'||quote_ident(tb.relname)||
' drop constraint '||quote_ident(conname)||';'||chr(10)||
'alter table '||quote_ident(ns.nspname)||'.'||quote_ident(tb.relname)||
' add constraint '||quote_ident(conname)||' '||
pg_get_constraintdef(c.oid, true)||';' as ddl
from pg_constraint c
join pg_class tb on tb.oid = c.conrelid
join pg_namespace ns on ns.oid = tb.relnamespace
where ns.nspname in ('public') --<<< adjust the schema name(s) here
and c.contype = 'f'; (edited)

Pulled from: https://dba.stackexchange.com/questions/125578/recreate-all-foreign-keys-in-all-tables-as-deferrable-batch 

Backup and Restore

See pgAdmin Backup and restore.pdf that Ty Toon created for RPC backups. Most of the steps should work for a local backup. See the differences below. The backup will be saved to the file path and name saved in the backup step.

The Key Difference: