We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a4ec5af commit e47e9c4Copy full SHA for e47e9c4
sql-queries-8/Save_PostgreSQL_Result_to_File/Save_PostgreSQL_Result_to_File.sql
@@ -0,0 +1,23 @@
1
+-- Using \o Command
2
+
3
+\o sql_result.txt --Specifying file path
4
+SELECT * from Student; --Storing Student record to the file
5
+\o --Resetting the output back to the terminal
6
7
8
9
+-- Using Command Line Redirection
10
+ -- exporting all rows from the Course table in the university database
11
+ psql -d university -c "SELECT * from Course;" > /var/lib/postgresql/course_data.txt
12
13
14
15
16
+-- Using COPY TO SQL
17
+ --exporting the content of the Department to the res.csv file
18
+COPY Department TO '/var/lib/postgresql/res.csv' DELIMITER ',' CSV HEADER;
19
20
21
22
23
0 commit comments