Solved

Postgre Sql Export query

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now