How to write big queries in PSQL
Suppose we are using PSQL (command line tool for postgresql) and want to write an big query like joins and where conditions. Here the problem is, as we are writing the query in command prompt, it will be hard to write big queries.
To solve this problem, we can use psql command "\e", this command will open the last executed query in notepad file. In this file we can write our lengthy queries, then save the file and close the file. Once after closing the file, psql will execute the query and will provide the result. Here we have to note one thing, that is psql will not show the query that we just write in the notepad file, to check what query executed, we can again use the command "\e".
Below is the examples of what we have read above.
To solve this problem, we can use psql command "\e", this command will open the last executed query in notepad file. In this file we can write our lengthy queries, then save the file and close the file. Once after closing the file, psql will execute the query and will provide the result. Here we have to note one thing, that is psql will not show the query that we just write in the notepad file, to check what query executed, we can again use the command "\e".
Below is the examples of what we have read above.
Comments
Post a Comment