I have a logs table in the data base database. For the second day I'm struggling to upload it in CSV format.
Commands like
copy logs to 'D:/CSV.csv' WITH CSV DELIMITER ',' HEADER;
don't help. The error logs relation does not exist always pops up, while an empty CSV file is created along the path specified in the command.
Either you are connected to a different database, or the schema ( public
?) is not on your search_path
. In the latter case, use
COPY public.logs TO 'D:/CSV.csv' (FORMAT 'csv', DELIMITER ',', HEADER);
Solving the problem:
Before using the command
Copy logs To 'D:/CSV.csv' With CSV DELIMITER ',' HEADER;
Needed:
Log in to psql with the command psql -U username
(according to the postgres standard)
The next step is to connect to the database where your table is located. In my case, this is \connect "data base"
And then you can copy the table in csv format with the command above.
I hope that this answer will help all newcomers in the same trouble.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.