Programming/PostgreSQL: Difference between revisions

From Dev Wiki
Jump to navigation Jump to search
(Move basic "access shell" commands to this page)
(Update links)
 
Line 10: Line 10:
== Syntax ==
== Syntax ==
* [[Programming/PostgreSQL/Databases | Databases]]
* [[Programming/PostgreSQL/Databases | Databases]]
* [[PostgresQL/Queries | Queries]]
* [[Programming/PostgreSQL/Table Queries | Table Queries]]
* [[PostgreSQL/Record Queries | Record Queries]]





Latest revision as of 01:21, 27 January 2023

PostgreSQL is an open source object-relational database.

It acts as an alternative to the common database MySQL.


Setup


Syntax


Basics

Accessing the PostgreSQL Shell

Access the PostgreSQL shell with:

psql -U <user_name> -d <database_name>

Exit the shell with:

\q

To access the PostgreSQL shell for the first time (prior to creating any additional users), invoke the postgres user:

sudo -u postgres psql

Accessing the Linux PostgreSQL Account

Sometimes (rarely), you'll want to access the actual Linux account made for PostgreSQL, rather than just the database user.
To do this, use:

sudo -i -u postgres

This is required for some commands, such as the createuser linux terminal command.