Skip to content

Commit af296d7

Browse files
authored
Save_PostgreSQL_Result_to_File.sql
1 parent 691eff9 commit af296d7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--Using \o Command
2+
\o sql_result.txt
3+
SELECT * from Student;
4+
\o
5+
6+
7+
--Using Command Line Redirection
8+
psql -d university -c "SELECT * from Course;" > /var/lib/postgresql/course_data.txt
9+
10+
11+
--Using COPY TO SQL
12+
COPY Department TO '/var/lib/postgresql/res.csv' DELIMITER ',' CSV HEADER;

0 commit comments

Comments
 (0)