470,581 Members | 2,357 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,581 developers. It's quick & easy.

New to list, quick question.

Hello everyone.
I have been using PostgreSQL for about 3-4 years now, it's wonderful how
I can make it do things and write Perl programs to interface with it.

Since I do all of the DBA behind the scenes on our company Intranet
(Linux-Apache based), and I really prefer writing Perl programs to do my
simple admin functions. I really like those \d commands (via telnet) and
they tell me a lot of what I need for writing new programs etc, but I
would really like a way to use those through my Perl programs, but
haven't found a way to do so, has anyone done this in this manner yet?
Also, I'd like a way to query a table to find out how much space it is
using, like it's percentage for example, is there a way to do that?

Excuse me if these questions have been asked before, I tried to search
the LIST area and I also did not see anything related to this in the FAQS.

Thanks for any info you can provide me.
--
Rich Parker
http://www.fssi-ca.com
mailto:Ri********@fssi-ca.com

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #1
1 1362
you can retrieve any information of tables by queryng the catalog of
your database. For example, to get a description of table "sales", you
can query:

SELECT
C.relname, A.attname, T.typname
FROM
pg_class C
INNER JOIN pg_attribute A ON(C.oid=A.attrelid)
INNER JOIN pg_type T ON (T.oid=A.atttypid)
WHERE
C.relname='sales';

from perl, php, c or whatever.

Here (http://www.postgresql.org/docs/7.3/i.../catalogs.html) is
the catalog tables documentation.

About your second question, you need to install contrb/dbsize. Then you
can query
SELECT relation_size('sales');
to get the size of your sales table.

On Fri, 2003-08-15 at 12:35, Rich Parker wrote:
Hello everyone.
I have been using PostgreSQL for about 3-4 years now, it's wonderful how
I can make it do things and write Perl programs to interface with it.

Since I do all of the DBA behind the scenes on our company Intranet
(Linux-Apache based), and I really prefer writing Perl programs to do my
simple admin functions. I really like those \d commands (via telnet) and
they tell me a lot of what I need for writing new programs etc, but I
would really like a way to use those through my Perl programs, but
haven't found a way to do so, has anyone done this in this manner yet?
Also, I'd like a way to query a table to find out how much space it is
using, like it's percentage for example, is there a way to do that?

Excuse me if these questions have been asked before, I tried to search
the LIST area and I also did not see anything related to this in the FAQS.

Thanks for any info you can provide me.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQA/PRnr21dVnhLsBV0RAgA/AJkBm28Gi8IP5fdRcdh8JZuqu0O6LwCfY15J
Vw5KR2iFogKVwnWWThpABp0=
=O03K
-----END PGP SIGNATURE-----

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by RAJASEKHAR KONDABALA | last post: by
13 posts views Thread by XXXXXX.working.in.my.blood | last post: by
4 posts views Thread by Tim Henderson | last post: by
reply views Thread by anna_parkins7 | last post: by
1 post views Thread by simplico | last post: by
10 posts views Thread by datamonkey.ryan | last post: by
8 posts views Thread by =?Utf-8?B?VHJlY2l1cw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.