Solved

Postgre Sql Export query

Posted on 2008-10-06
4
903 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

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

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…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

635 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