Created
February 2, 2018 16:27
-
-
Save miceno/311188ed34efa0ad13b3b29c70d13238 to your computer and use it in GitHub Desktop.
Export and import CSV in postgres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- On the server. | |
-- \copy is run on the client side, so if you run in your local machine to connect to the remote | |
-- server, you will transfer the results probably in plain. So better run it on local. | |
\copy (Select * From sns_log where received > '2018-01-01') To '/tmp/log-20180101.csv' With CSV delimiter ',' | |
-- On the client side. | |
\COPY sns_log FROM 'log-20180101.csv' WITH delimiter as ',' csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment