How to export data to a CSV file from a PostgreSQL database

  1. Type in the following command in postgres using the command line:
    copy products to ‘/home/user/products.csv’ delimiters ‘,’

    • products = (Database Table)
    • ‘/home/user/products.csv‘ = (Location where to save the csv file)
    • You need to have write permissions to write the file to the filesystem with the postgres user

How to import a CSV file into a postgresql?

Image Credits: Photo by Isis França on Unsplash.

More Similar Posts

No results found.