Skip to content

Commit cd7dd50

Browse files
authored
Merge pull request #353 from Mateen0007/main
Save PostgreSQL Result to a File
2 parents 277080a + 44b3e2d commit cd7dd50

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)