Solved

Postgre Sql Export query

Posted on 2008-10-06
4
899 Views
Last Modified: 2012-05-05
  Is there any kind of query that i can use to export my data in postgresql that i select with special conditions ?

   If thereisnt something like that , i am currently using phpPgadmin is it possible to do it from there ?

   If not , than which 3 hd party tool should i use ?

  Notice : I am not talking about exporting data in a database or in a specific table , i need to export data which i can apply WHERE clause.
0
Comment
Question by:ali_kayahan
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
thewild earned 500 total points
ID: 22650215
Yes, you can use PostgreSQL's COPY command do achieve that.

http://www.postgresql.org/docs/8.3/static/sql-copy.html

The file will be exported to a path relative to your SERVER installation. If your server is running under an account that has sufficient rights, it wan write to a network share.
COPY (SELECT * FROM mytable WHERE somecolumn = somevalue) TO E'C:\\myexportedfile.txt';

Open in new window

0
 
LVL 14

Author Comment

by:ali_kayahan
ID: 22650376
Thanks thewild , i wonder if is it possible to export it as xls keeping the tabular data ?
0
 
LVL 4

Expert Comment

by:thewild
ID: 22650447
You can export it as CSV.
CSV is "Comma Separated Value", and it will open in Excel just fine (I even think that ".csv" files are associated to Excel whenever you install MS Office).
Just add "CSV" (without the quotes) at teh very end of your COPY command.
0
 
LVL 14

Author Comment

by:ali_kayahan
ID: 22650494
Thanks
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question