Skip to content

Commit

Permalink
update (github#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobprall authored Oct 19, 2021
1 parent feb2cdd commit c994d30
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions timescaledb/how-to-guides/psql-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ For an in-depth breakdown of all commands, visit [psql's documentation](https://

## Connections

* Connect to a PostgreSQL/TimescaleDB server via psql (using parameter flags):
Connect to a PostgreSQL/TimescaleDB server via psql (using parameter flags):

```bash
psql -h host_name -p port -U username -W -d database_name
```

* Connect to a PostgreSQL/TimescaleDB server via psql (using a service URL):
Connect to a PostgreSQL/TimescaleDB server via psql (using a service URL):

```bash
psql "your_service_URL"
```

* Show your psql version
Show your psql version
```bash
psql --version
```
Expand Down Expand Up @@ -98,7 +98,7 @@ The commands in this section can be used to import and export CSV files from you

<tab label="Export">

```
```sql
\copy (SELECT * FROM table_name) TO 'output_file.csv' WITH CSV HEADER

```
Expand All @@ -116,36 +116,36 @@ The commands in this section use the `pg_dump` and `pg_dumpall` tools.
Create a backup for a specific database in plan-text SQL script file
(with default backup options)

```sql
```bash
pg_dump database_name > database_name.bak.sql
```

Creates a backup for a specific database in plan-text SQL script file (with customized backup options)

```
```bash
pg_dump -c -C -F p -f database_name.bak.sql database_name
```

Run pg_dump on a client computer to back up data on a remote Postgres server

```
```bash
pg_dump -h remote_host -p port -U user -f database_name.bak mydb
```

Backup all databases along with database roles and cluster-wide information

```
```bash
pg_dumpall > alldb.bak.sql
```

Restore the database plain-text backup generated by pg_dump or pg_dumpall

```
```bash
psql -U username -f filename.sql
```

Restore the database custom-archive backup (.bak)

```
```bash
pg_restore -d database_name /path/to/your/file/database_name.bak -c -U database_user
```

0 comments on commit c994d30

Please sign in to comment.