Programming/PostgreSQL: Difference between revisions

From Dev Wiki
Jump to navigation Jump to search
(Update links)
(Update links)
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:


It acts as an alternative to the common database [[Programming/MySQL|MySQL]].
It acts as an alternative to the common database [[Programming/MySQL|MySQL]].


== Setup ==
== Setup ==
* [[Programming/PostgreSQL/Setup | Setup]]
* [[Programming/PostgreSQL/Setup | Setup]]


== Syntax ==
== Syntax ==
* [[Programming/PostgreSQL/Databases | Databases]]
* [[Programming/PostgreSQL/Databases | Databases]]
* [[PostgresQL/Queries | Queries]]
* [[Programming/PostgreSQL/Table Queries | Table Queries]]
* [[PostgreSQL/Record Queries | Record Queries]]
 
 
== 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 {{ ic |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.<br>
To do this, use:
sudo -i -u postgres
 
This is required for some commands, such as the [[Programming/PostgreSQL/Setup#Create User | createuser ]] linux terminal command.

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.