@@ -9,19 +9,19 @@ For an in-depth breakdown of all commands, visit [psql's documentation](https://
99
1010## Connections
1111
12- * Connect to a PostgreSQL/TimescaleDB server via psql (using parameter flags):
12+ Connect to a PostgreSQL/TimescaleDB server via psql (using parameter flags):
1313
1414``` bash
1515psql -h host_name -p port -U username -W -d database_name
1616```
1717
18- * Connect to a PostgreSQL/TimescaleDB server via psql (using a service URL):
18+ Connect to a PostgreSQL/TimescaleDB server via psql (using a service URL):
1919
2020``` bash
2121psql " your_service_URL"
2222```
2323
24- * Show your psql version
24+ Show your psql version
2525``` bash
2626psql --version
2727```
@@ -98,7 +98,7 @@ The commands in this section can be used to import and export CSV files from you
9898
9999<tab label =" Export " >
100100
101- ```
101+ ``` sql
102102\copy (SELECT * FROM table_name) TO ' output_file.csv' WITH CSV HEADER
103103
104104```
@@ -116,36 +116,36 @@ The commands in this section use the `pg_dump` and `pg_dumpall` tools.
116116Create a backup for a specific database in plan-text SQL script file
117117 (with default backup options)
118118
119- ``` sql
119+ ``` bash
120120pg_dump database_name > database_name.bak.sql
121121```
122122
123123Creates a backup for a specific database in plan-text SQL script file (with customized backup options)
124124
125- ```
125+ ``` bash
126126pg_dump -c -C -F p -f database_name.bak.sql database_name
127127```
128128
129129Run pg_dump on a client computer to back up data on a remote Postgres server
130130
131- ```
131+ ``` bash
132132pg_dump -h remote_host -p port -U user -f database_name.bak mydb
133133```
134134
135135Backup all databases along with database roles and cluster-wide information
136136
137- ```
137+ ``` bash
138138pg_dumpall > alldb.bak.sql
139139```
140140
141141Restore the database plain-text backup generated by pg_dump or pg_dumpall
142142
143- ```
143+ ``` bash
144144psql -U username -f filename.sql
145145```
146146
147147Restore the database custom-archive backup (.bak)
148148
149- ```
149+ ``` bash
150150pg_restore -d database_name /path/to/your/file/database_name.bak -c -U database_user
151151```
0 commit comments