Urgent help needed! Trouble getting column names from tables
Urgent help needed! Trouble getting column names from tables
am 26.06.2007 14:31:04 von intel.g33k
Good morning,
I was given some tables on an Oracle database, but unfortunately I do
not know the field/column names of the table. I've made numerous
attempts to print such a list for a given table, but they never seem
to work. I've been trying SQL queries such as:
SELECT column_name FROM user_tab_cols WHERE table_name =
'mytable'sname'
Sometimes I'm able to get them to run with no errors... yet no result
is produced when I try to print them. I'm not sure if there is some
trick with DBI that I'm overlooking. Any tips would be greatly
appreciated!
Cheers,
Kacey
Re: Urgent help needed! Trouble getting column names from tables
am 26.06.2007 16:00:07 von Martin.Evans
intel.g33k@gmail.com wrote:
> Good morning,
>
> I was given some tables on an Oracle database, but unfortunately I do
> not know the field/column names of the table. I've made numerous
> attempts to print such a list for a given table, but they never seem
> to work. I've been trying SQL queries such as:
>
> SELECT column_name FROM user_tab_cols WHERE table_name =
> 'mytable'sname'
>
> Sometimes I'm able to get them to run with no errors... yet no result
> is produced when I try to print them. I'm not sure if there is some
> trick with DBI that I'm overlooking. Any tips would be greatly
> appreciated!
>
> Cheers,
> Kacey
>
>
If you only want the info about columns in a table have you tried:
$sth = $dbh->column_info( $catalog, $schema, $table, $column );
I would guess if you get no result, the where clause is not matching a
table.
column_info is the portable way to do it.
Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com
Re: Urgent help needed! Trouble getting column names from tables
am 26.06.2007 16:01:28 von hwigoda
i think there is a syscolumns and systables tables that contain that
data.
On Jun 26, 2007, at 7:31 AM, intel.g33k@gmail.com wrote:
> Good morning,
>
> I was given some tables on an Oracle database, but unfortunately I do
> not know the field/column names of the table. I've made numerous
> attempts to print such a list for a given table, but they never seem
> to work. I've been trying SQL queries such as:
>
> SELECT column_name FROM user_tab_cols WHERE table_name =
> 'mytable'sname'
>
> Sometimes I'm able to get them to run with no errors... yet no result
> is produced when I try to print them. I'm not sure if there is some
> trick with DBI that I'm overlooking. Any tips would be greatly
> appreciated!
>
> Cheers,
> Kacey
>
RE: Urgent help needed! Trouble getting column names from tables
am 26.06.2007 16:25:03 von Philip.Garrett
intel.g33k@gmail.com wrote:
> Good morning,
>=20
> I was given some tables on an Oracle database, but unfortunately I do
> not know the field/column names of the table. I've made numerous
> attempts to print such a list for a given table, but they never seem
> to work. I've been trying SQL queries such as:
>=20
> SELECT column_name FROM user_tab_cols WHERE table_name =3D
> 'mytable'sname'
>=20
> Sometimes I'm able to get them to run with no errors... yet no result
> is produced when I try to print them. I'm not sure if there is some
> trick with DBI that I'm overlooking. Any tips would be greatly
> appreciated!
Well I suppose you could use DBI for this, but why? Just run "desc
" in sqlplus.
- Philip
Re: Urgent help needed! Trouble getting column names from tables
am 27.06.2007 17:56:08 von intel.g33k
On Jun 26, 10:25 am, Philip.Garr...@manheim.com (Philip Garrett)
wrote:
> intel.g...@gmail.com wrote:
> > Good morning,
>
> > I was given some tables on an Oracle database, but unfortunately I do
> > not know the field/column names of the table. I've made numerous
> > attempts to print such a list for a given table, but they never seem
> > to work. I've been trying SQL queries such as:
>
> > SELECT column_name FROM user_tab_cols WHERE table_name =
> > 'mytable'sname'
>
> > Sometimes I'm able to get them to run with no errors... yet no result
> > is produced when I try to print them. I'm not sure if there is some
> > trick with DBI that I'm overlooking. Any tips would be greatly
> > appreciated!
>
> Well I suppose you could use DBI for this, but why? Just run "desc
> " in sqlplus.
>
> - Philip
Thank you everyone for your help! I was eventually able to get it to
work using:
$sth = $dbh->prepare("select table_name, column_name from
all_tab_columns where table_name = 'mytablesname'");
I will test out your other solutions, though. I appreciate the help
greatly!
Re: Urgent help needed! Trouble getting column names from tables
am 28.06.2007 02:18:59 von ron
Hi Folks
There are Perl modules designed to solve this problem. One is:
http://search.cpan.org/~rsavage/DBIx-Admin-TableInfo-2.00/
--
Ron Savage
ron@savage.net.au