Re: Basic Tutorials for 9.0 - Mailing list pgsql-general

From Alban Hertroys
Subject Re: Basic Tutorials for 9.0
Date
Msg-id A47F027A-C98E-495A-98E2-920E33F005AB@solfertje.student.utwente.nl
Whole thread Raw
In response to Re: Basic Tutorials for 9.0  (ray <ray@aarden.us>)
List pgsql-general
On 13 Nov 2010, at 3:44, ray wrote:

> On Nov 10, 11:07 pm, robjsarg...@gmail.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
probablyhas 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
setup. 

> 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
andcopy 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
fromthe 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
tolook 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
ofthat. There are plenty more possibilities. 

Alban Hertroys

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


!DSPAM:737,4cde80ae10261879520974!



pgsql-general by date:

Previous
From: Elliot Chance
Date:
Subject: The first dedicated PostgreSQL forum
Next
From: Merlin Moncure
Date:
Subject: Re: Insert data with greek characters using psql environment