Programming/PostgreSQL: Difference between revisions
Jump to navigation
Jump to search
Brodriguez (talk | contribs) m (Brodriguez moved page PostgreSQL to Programming/PostgreSQL) |
Brodriguez (talk | contribs) (Update links) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[https://www.postgresql.org/ PostgreSQL] is an open source object-relational database. | [https://www.postgresql.org/ PostgreSQL] is an open source object-relational database. | ||
It acts as an alternative to the common database [[Programming/MySQL]]. | It acts as an alternative to the common database [[Programming/MySQL|MySQL]]. | ||
== Setup == | == Setup == | ||
[[PostgreSQL/Setup]] | * [[Programming/PostgreSQL/Setup | Setup]] | ||
== Syntax == | == Syntax == | ||
[[PostgreSQL/Databases]] | * [[Programming/PostgreSQL/Databases | Databases]] | ||
[[ | * [[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.