Re: [DBI] Structure of table?
> I wonder if there is a legal way using the DBI driver for Perl to
> gain information about the structure of the table, especially the
> length of some fields.
I think there is no DBI function that would do it uniformly for all
databases, but for most of them you could execute a "SELECT" query
which would give you desired result.
For example, in PostgreSQL
SELECT a.attnum, a.attname, t.typname, a.attlen
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = 'yourtable'
and a.attnum > 0
and a.attrelid = c.oid
and a.atttypid = t.oid
ORDER BY attnum
Hope it helps.
Alex Y.
--
_
_( )_
( (o___ +-------------------------------------------+
| _ 7 | Alexander Yukhimets |
\ (") | http://pages.nyu.edu/~aqy6633/ |
/ \ \ +-------------------------------------------+
Reply to: