Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add redirect from PSQL to PostgreSQL and improve PostgreSQL #2088

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions postgresql.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
---
title: PostgreSQL
category: Databases
layout: 2017/sheet

category: Databases
updated: 2024-01-15
intro: |
PostgreSQL is a powerful, open source object-relational database system.
It provides the `psql` command line tool for interacting with its database.
---

### Console
### Create Database

```shell
createdb <databasename>
```

$ psql #logs in to default database & default user
$ sudo -u <rolename:postgres> psql #logs in with a particular user
### Query Database

Replace anything within `<placeholder>` accordingly
```shell
psql --no-align --tuples-only --command="SELECT * FROM <table>" # Useful for scripting
psql -Atc "SELECT * FROM <table>" # short version of above
```

### Commands
### Login to Database

* Show roles: `\du`
* Show tables: `\dt`
* Show databases: `\l`
* Connect to a database: `\c <database>`
* Show columns of a table: `\d <table>` or `\d+ <table>`
* Quit: `\q`
```shell
psql # logs in to default database & default user
sudo -u <rolename:postgres> psql # logs in with a particular user
```

### Creating database
#### Commands

$ createdb databasename
* Show roles: `\du`
* Show tables: `\dt`
* Show databases: `\l`
* Connect to a database: `\c <database>`
* Show columns of a table: `\d <table>` or `\d+ <table>`
* Quit: `\q`
6 changes: 6 additions & 0 deletions psql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# redirect to postgresql.md
---
title: PSQL
category: Hidden
redirect_to: /postgresql.md
---
Loading