2

In the answer to How to manage DEFAULT PRIVILEGES for USERs on a DATABASE vs SCHEMA?

I see the line \connect hostdb why and when do I need this line?

I'm executing role creations SQL line from a .sql file

Bart Jonk
  • 305
  • 1
  • 3
  • 9

1 Answers1

3

That's needed because the target database for the rest of that script is created just in the line above that statement. However creating a new database doesn't automatically switch to that database. In order for all following statements to be executed against that new database, the connection needs to be switched to that database.