LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-15-2010, 11:54 PM   #1
gnurich
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Rep: Reputation: 0
importing database in postgres


i have made a schema in postgres in which i want to import data from MS Excel sheet.Like in PHP there's no direct option of importing tables in database.plz suggest.

Another problem that i am facing is in making an audit trail of a table where i am trying to get primary key name and primary key value.i am unable to build the function properly.plz guide and if possible with the code.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 01-16-2010, 08:19 AM   #2
emi_ramo
Member
 
Registered: Apr 2007
Location: Barcelona, Spain
Distribution: Debian, KUbuntu
Posts: 213

Rep: Reputation: 36
For DB importing:
  1. Save Excel table with CSV format, with tabs instead of commas
  2. Edit the file with a text editor
  3. Add a line before the data:
    Code:
    COPY TableName (col1,col2,etc) FROM stdin;
  4. Add a line after the data:
    Code:
    \.
    (backslash dot)
  5. Import the table as usual:
    Code:
    psql -U USER -f FILE DATABASE
 
2 members found this post helpful.
  


Reply

Tags
postgresql


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Query a postgres database with Java cov Linux - Server 1 12-12-2009 10:29 AM
Starting a postgres database at boot kchakrak Linux - Software 1 01-08-2009 06:49 AM
Scripts updating a postgres database ethnicme Programming 1 07-15-2006 11:21 AM
create table in postgres database kranti Linux - Newbie 1 11-15-2005 07:52 PM
changing password for postgres database anjani.78 Linux - Software 1 07-18-2005 11:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration