Solved

Postgre Sql Export query

Posted on 2008-10-06
4
897 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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