pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedDesc Commnad in pgsql?
6+ messages / 6 participants
[nested] [flat]
* Desc Commnad in pgsql?
@ 2008-04-17 08:47 VG <vikasraigupta@gmail.com>
0 siblings, 3 replies; 6+ messages in thread
From: VG @ 2008-04-17 08:47 UTC (permalink / raw)
To: pgsql-sql
Hello All,
I like to know how can I achieve the same functionality that is give by desc
commnad in mysql or oracle.
Also specify me the book related to pgsql as a beginner.
Presently my task is going to be communication of ruby with pgsql
Thanks in advanced.
Vikas
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Desc Commnad in pgsql?
@ 2008-04-17 08:53 A. Kretschmer <andreas.kretschmer@schollglas.com>
parent: VG <vikasraigupta@gmail.com>
2 siblings, 0 replies; 6+ messages in thread
From: A. Kretschmer @ 2008-04-17 08:53 UTC (permalink / raw)
To: pgsql-sql
am Thu, dem 17.04.2008, um 14:17:45 +0530 mailte VG folgendes:
>
>
> Hello All,
>
> I like to know how can I achieve the same functionality that is give by desc
> commnad in mysql or oracle.
'desc'? descending, describe, desc...
wild guess: describe, like ORA. You can use \d within psql, please read
the welcome-message.
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Desc Commnad in pgsql?
@ 2008-04-17 08:59 Richard Huxton <dev@archonet.com>
parent: VG <vikasraigupta@gmail.com>
2 siblings, 0 replies; 6+ messages in thread
From: Richard Huxton @ 2008-04-17 08:59 UTC (permalink / raw)
To: VG <vikasraigupta@gmail.com>; +Cc: pgsql-sql
VG wrote:
> Hello All,
>
> I like to know how can I achieve the same functionality that is give by desc
> commnad in mysql or oracle.
http://www.postgresql.org/docs/8.3/static/app-psql.html
See the \d command, e.g. "\d mytable"
There are many different backslash commands that can give you details on
tables, views, functions, schemas etc.
> Also specify me the book related to pgsql as a beginner.
http://www.postgresql.org/docs/8.3/static/index.html
http://www.postgresql.org/docs/books/
> Presently my task is going to be communication of ruby with pgsql
Start here I suppose:
http://rubyforge.org/projects/ruby-pg/
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Desc Commnad in pgsql?
@ 2008-04-19 16:55 Christopher Browne <cbbrowne@acm.org>
parent: VG <vikasraigupta@gmail.com>
2 siblings, 0 replies; 6+ messages in thread
From: Christopher Browne @ 2008-04-19 16:55 UTC (permalink / raw)
To: pgsql-sql
The world rejoiced as vikasraigupta@gmail.com (VG) wrote:
> Hello All,
> I like to know how can I achieve the same functionality that is give by desc commnad in mysql or oracle.
> Also specify me the book related to pgsql as a beginner.
> Presently my task is going to be communication of ruby with pgsql
> Thanks in advanced.
If you were referring to the usage of "desc" to indicate "descending
order", as in:
select * from some table order by id desc
well, that's pretty standard SQL usage, and will work much as it
would in MySQL(tm) or Oracle.
If you're looking for ways to "describe" a table, there are two
mechanisms:
1. SQL standard (probably SQL:1993) describes an
"information_schema" which contains tables or views that allow
querying database metadata in a fairly standard fashion.
PostgreSQL supports that.
2. Probably easier and friendlier, albeit nonportable, is to use
the psql "\d" command.
Here's an example:
cbbrowne@wolfe:~> psql ledgersmb Saturday 12:51:13
Welcome to psql 8.1.10, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
ledgersmb=# \d acc_trans
Table "public.acc_trans"
Column | Type | Modifiers
----------------+---------+-------------------------------------------------------------
trans_id | integer |
chart_id | integer | not null
transdate | date | default date('now'::text)
source | text |
cleared | boolean | default false
fx_transaction | boolean | default false
project_id | integer |
memo | text |
invoice_id | integer |
amount | numeric |
entry_id | bigint | not null default nextval('acctrans_entry_id_seq'::regclass)
Indexes:
"acc_trans_pkey" PRIMARY KEY, btree (entry_id)
"acc_trans_chart_id_key" btree (chart_id)
"acc_trans_source_key" btree (lower(source))
"acc_trans_trans_id_key" btree (trans_id)
"acc_trans_transdate_key" btree (transdate)
Foreign-key constraints:
"$1" FOREIGN KEY (chart_id) REFERENCES chart(id)
"$2" FOREIGN KEY (chart_id) REFERENCES chart(id)
"$3" FOREIGN KEY (chart_id) REFERENCES chart(id)
"$4" FOREIGN KEY (chart_id) REFERENCES chart(id)
"acc_trans_chart_id_fkey" FOREIGN KEY (chart_id) REFERENCES chart(id)
You can query the schemas for all sorts of objects, complete with
tab-completion; type "\?" at the psql prompt to see all of the
internal psql commands. There is a whole section entitled
"Informational" that shows modifiers to \d to query various sorts of
objects.
For instance:
\dt will list all tables
\ds will list all sequences
\dv will list all views
and there's a further cast of ~20 variants for various different sorts
of objects.
--
let name="cbbrowne" and tld="gmail.com" in String.concat "@" [name;tld];;
http://linuxdatabases.info/info/postgresql.html
"Java and C++ make you think that the new ideas are like the old ones.
Java is the most distressing thing to hit computing since MS-DOS."
-- Alan Kay
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Desc Commnad in pgsql?
@ 2008-04-21 00:14 TJ O'Donnell <tjo@acm.org>
0 siblings, 1 reply; 6+ messages in thread
From: TJ O'Donnell @ 2008-04-21 00:14 UTC (permalink / raw)
To: cbbrowne@acm.org; pgsql-sql
I like the table and other info from psql
and find I sometimes need that info in my client programs.
Are there any SQL/plpgsql functions that are analogous
to the psql \dt, \ds, etc. commands?
For example
create function d_table(table_name text) returns setof record
that could be used in SQL commands in client programs?
I am not concerned whether these are compatible with other
RDBMS.
TJ O'Donnell
http://www.gnova.com
>
> If you're looking for ways to "describe" a table, there are two
> mechanisms:
>
> 1. SQL standard (probably SQL:1993) describes an
> "information_schema" which contains tables or views that allow
> querying database metadata in a fairly standard fashion.
>
> PostgreSQL supports that.
>
> 2. Probably easier and friendlier, albeit nonportable, is to use
> the psql "\d" command.
>
> >>
>> For instance:
>> \dt will list all tables
>> \ds will list all sequences
>> \dv will list all views
>> and there's a further cast of ~20 variants for various different sorts
>> of objects.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Desc Commnad in pgsql?
@ 2008-04-21 13:36 Alvaro Herrera <alvherre@commandprompt.com>
parent: TJ O'Donnell <tjo@acm.org>
0 siblings, 0 replies; 6+ messages in thread
From: Alvaro Herrera @ 2008-04-21 13:36 UTC (permalink / raw)
To: TJ O'Donnell <tjo@acm.org>; +Cc: cbbrowne@acm.org; pgsql-sql
TJ O'Donnell wrote:
> I like the table and other info from psql
> and find I sometimes need that info in my client programs.
> Are there any SQL/plpgsql functions that are analogous
> to the psql \dt, \ds, etc. commands?
If you start psql with the -E option it will show you the queries it
used to build the response tables.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2008-04-21 13:36 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-04-17 08:47 Desc Commnad in pgsql? VG <vikasraigupta@gmail.com>
2008-04-17 08:53 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
2008-04-17 08:59 ` Richard Huxton <dev@archonet.com>
2008-04-19 16:55 ` Christopher Browne <cbbrowne@acm.org>
2008-04-21 00:14 Re: Desc Commnad in pgsql? TJ O'Donnell <tjo@acm.org>
2008-04-21 13:36 ` Alvaro Herrera <alvherre@commandprompt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox