Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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 :: rename column name sql server 
Sql :: sub query in linq 
Sql :: create table as select * from table mssql 
Sql :: sql stored procedure update if parameter is not null 
Sql :: view table mysql 
Sql :: postgresql full text search 
Sql :: replace text in sql 
Sql :: duplicate key value violates unique constraint in postgresql 
Sql :: GROUP BY With HAVING Clausel 
Sql :: minus in sql 
Sql :: c# select Mysql 
Sql :: how to get initials in sql 
Sql :: postgresql default value 
Sql :: mysql connectiion timeout 
Sql :: How to insert Arabic characters into SQL database 
Sql :: sql delete duplicate 
Sql :: SQL Syntax of LEFT JOIN 
Sql :: SQL Subtraction Operator 
Sql :: find mysql password 
Sql :: sql left join 
Sql :: SQL Rename Column in a Table 
Sql :: truncate table in sql 
Sql :: sql find leading space 
Sql :: update value sql 
Sql :: sql restore database from backup 
Sql :: sql rename table 
Sql :: sql get month and year from date 
Sql :: porcentaje sql 
Sql :: union vs union all in sql 
Sql :: what is non relational database 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =