Re: Basic Tutorials for 9.0

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: ray <ray(at)aarden(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Basic Tutorials for 9.0
Date: 2010-11-13 12:11:58
Message-ID: A47F027A-C98E-495A-98E2-920E33F005AB@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 13 Nov 2010, at 3:44, ray wrote:

> On Nov 10, 11:07 pm, robjsarg(dot)(dot)(dot)(at)gmail(dot)com (Rob Sargent) wrote:
>> ray wrote:
>>> I also tried the shell. create mydb. I used all the defaults but the
>>> console came back and rejected all the defaults and closed the
>>> console.
>>
>>> I would like to export an Excel file as CVS and ;'copy' into pg. So I
>>> would like to learn how to create a new database and what ever goes
>>> along with that to acheive this goal.
>>
>>> I would appreciate all help.
>>
>>> Thanks,
>>> ray
>>
>> if the defaults are in play the owning account should be able to do
>>
>> createdb somedbname;
>>
>> You left of the "db" in createdb in your posting.

> I really didn't understand. I was trying to create a new db inside of
> the pg shell. I found that I needed to do it at the OS command
> prompt. This was totally unclear in the manual.

That's not true, it's just that the command you used wouldn't have worked in either.

On the OS shell's command line (cmd in Windows) you use "createdb mydb" to create a database,
in the psql shell you use "CREATE DATABASE mydb;".
I expect the latter command would work in pgadmin too (although you may have to leave out the semi-colon), but it probably has a convenient menu option for creating databases somewhere.

I tend to install MSys in Windows so that I have a proper UNIX shell to run those commands from, but it's a bit hard to set up.

> Now I have found that the copy cammand is to be done in the shell.

If you're saying shell, do you mean your OS shell (cmd.exe) or are you talking about the psql shell?

To copy data you can use either the \copy command built in the psql shell, or you can use the COPY statement directly and copy from STDIN, followed by your CSV data and closed with a \. terminator.
Check the documentation on COPY for details and examples.

> Now if I could just find out if it is working. I can't seem to look into the db.

I guess you're talking about pgadmin here, with which I'm not familiar. It's probably just not connected to your database, guessing from your earlier remark about the red X.
Is the database server on the same machine as pgadmin? If not, you probably need to edit pg_hba.conf to allow access from the machine running pgadmin.

In the psql shell you can type \dt to see your tables (or \? for a list of built-in commands) and use SELECT statements to look at your data.

You could also try to hook up an ODBC connection to your database and look at it using Access or Openoffice's variant of that. There are plenty more possibilities.

Alban Hertroys

--
Screwing up is an excellent way to attach something to the ceiling.

!DSPAM:737,4cde80ae10261879520974!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2010-11-13 15:58:11 Re: Insert data with greek characters using psql environment
Previous Message Tom Lane 2010-11-13 03:49:35 Re: More then 1600 columns?