Output result of a select query to a file using \o
1) \o /tmp/mydata.txt
2) select * from some_table;
You will notice that result in the /tmp/mydata.txt file
Read content of a file for updating or inserting
1) Set the content of a file to the variable
\set content = `cat /tmp/read_content.text`
2) refer this variable in query
update my_table set data = :'content' where id = 411;
1) \o /tmp/mydata.txt
2) select * from some_table;
You will notice that result in the /tmp/mydata.txt file
Read content of a file for updating or inserting
1) Set the content of a file to the variable
\set content = `cat /tmp/read_content.text`
2) refer this variable in query
update my_table set data = :'content' where id = 411;
No comments:
Post a Comment