Search
 
SCRIPT & CODE EXAMPLE
 

SQL

PostgreSQL to a CSV file

-- Client side -This approach does the file handling on the client side
Copy (Select * From foo) To '/tmp/test.csv' With CSV DELIMITER ',' HEADER

-- Server side - This approach runs entirely on the remote server
Copy (Select * From foo) To '/tmp/test.csv' With CSV DELIMITER ',' HEADER;
Comment

run postgresql dump to csv


        
            
        
     copy (SELECT * FROM persons) to 'C:	mppersons_client.csv' with csv
Comment

Save PL/pgSQL output from PostgreSQL to a CSV file

>psql dbname
psql>f ','
psql>a
psql>o '/tmp/output.csv'
psql>SELECT * from users;
psql>q

----------------------------------
COPY (SELECT * from users) To '/tmp/output.csv' With CSV;

-----------------------------------------
psql -d dbname -t -A -F"," -c "select * from users" > output.csv


Comment

PREVIOUS NEXT
Code Example
Sql :: postgresql Create a new role with a username and password 
Sql :: how to find third highest salary in sql 
Sql :: sqlite get last 
Sql :: oracle temporary table 
Sql :: oracle login as sysdba 
Sql :: json extract 
Sql :: postgresql function 
Sql :: sql paging query 
Sql :: check database size in gb mysql 
Sql :: if in mysql 
Sql :: sql select case when 
Sql :: sql query for getting data with join and count 
Sql :: between from sql 
Sql :: postgresql delete multiple rows 
Sql :: python uuid sqlalchemy 
Sql :: mysql multiple order by 
Sql :: division by zero postgres 
Sql :: query distinct 
Sql :: restart serial number for postgres 
Sql :: 11:04:35 PM [mysql] Error: MySQL shutdown unexpectedly. 11:04:35 PM [mysql] This may be due to a blocked port, missing dependencies, 
Sql :: sql select lowest value row 
Sql :: how to ascending order in sql 
Sql :: if mysql 
Sql :: sql server list database 
Sql :: sql datitime to date 
Sql :: how to find unique key in sql 
Sql :: sql query to check if column contains alphabets 
Sql :: psql generate id in existing database 
Sql :: sql alchemy or 
Sql :: postgres how to add field created at 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =