When successfully executed, it will create a csv file named books directly under C:\ drive. Note: Make sure that the specified path has read/write permission else ' permission denied' error would be thrown as shown below: Now let us take a look at the syntax to export the above table as a csv file, COPY table_name TO 'path/file_name.csv' CSV HEADER \copy books to 'C:/books.csv' CSV HEADER ('What Young India Wants', 'Chetan Bhagat', 'non-fiction') Īfter executing both the queries, the table should like this: ('James Bond', 'Ian Fleming', 'thriller'), VALUES('Tell me your dreams', 'Sidney Sheldon', 'thriller'), ) INSERT INTO books(book_name, author_name, genre) Let us first create a table and enter the some data into it to explore the technique. It is absolutely necessary that one working with relational databases must know how to complete this task. The following article can help you learn about PostgreSQL tables and if you are already aware of it, feel free skip to the next section of the article: Export PostgreSQL table to CSV fileĮxporting a table to a CSV file is one of the most important and commonly used features in practical world, be it in PostgreSQL or any other database platform. The only prerequisite for this article is to have decent knowledge of SQL table. Let us take a look at the topics we will cover in this article: In this article, we will cover a very important technique of working with a PostgreSQL table.
0 Comments
Leave a Reply. |