Monday, August 31, 2009

Using the psql Client

Connecting to a Database :

After Installing PostgreSQL you can login in psql client as following
$ psql -d movies

Welcome to psql, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

movies=# \q

The psql program is a text-based interface to a PostgreSQL database. When you are running
psql, you won't see a graphical application no buttons or pictures or other bells and whistles,
just a text-based interface. Later, I'll show you another client application that does provide a
graphical interface

A Simple Query :

At this point, you should be running the psql client application. Let's try a very simple query:

$ psql -d movies
Welcome to psql, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

movies=# SELECT user;

current_user
---------------
Deepu
(1 row)

movies=# \q

No comments:

Post a Comment

Followers