input query from file output result to file
I have a complex query I am testing some performance issues against, I want to load the query from file and be able to explain the query, profile the query etc but I also want to output the result from the query / explain plan to another file for comparisons
0
Comments
Below are two options for your requirement:
1.
To execute commands from a specific file:
===============================
\i <filename>
This command reads input from the file filename and executes it as though it had been typed on the keyboard.
Eg:
dbadmin=> \i query1.sql
2.
To create a file of output of commands:
======================================
\o meta-command is used to control where vsql directs its query output.
The output can be written to a file, piped to a shell command, or sent to the standard output.
\o FILE sends all subsequent query output to FILE.
Eg:
dbadmin> \o a.out
dbadmin> execute set of queries .....
dbadmin> \o
Regards'
Abhishek
I thought as follows would work but it didn't seem to:
dbadmin> \i Input_Query.sql \o output_result.txt
With above all i got was a blank output file ..
Thanks
dbadmin=> cat a.sql | vsql -p 5433 -w password -o out.txt
where , a.sql is sql file.
And out.txt is file which stores the output.
Regards'
Abhishek
Everything is possible if to think a little, just change an order of meta commands: Example