Export to CSV
The shortcut command to export a table into CSV
We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
COPY videos(id, title)
to '/Users/computername/Desktop/example-with-column-names.csv'
delimiter ',' csv header;
COPY
(
SELECT id, title
FROM videos
WHERE edition_id = 144
)
to '/Users/computername/Desktop/videos_with_tags.csv'
delimiter ',' csv header;
I would like a CSV of all the videos that contain a tag.
The video_tags
table is a join table and can be looked this way.
COPY
(SELECT title, id
FROM videos v
WHERE EXISTS
(SELECT 1 FROM videos_tags p WHERE p.video_id = v.id)
)
to '/Users/computername/Desktop/videos_with_tags.csv'
delimiter ',' csv header;
I would like a CSV of all the videos that have no tags.
The video_tags
table is a join table and can be looked this way.
COPY
(SELECT id,title
FROM videos v
WHERE NOT EXISTS
(SELECT 1 FROM videos_tags p WHERE p.video_id = v.id)
)
to '/Users/computername/Desktop/videos_with_no_tags.csv'
delimiter ',' csv header;