Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do perls dbi:Oracle table_info/column_info get their information from?

Tags:

oracle

perl

dbi

I've got an (at least i thought so) simple task: Comparing 2 tables by columnnames, datatypes and length only to verify they have the same structure so far. It should be done in an existing perl script which is connecting to two different databases.

First I simply queried each databases user_tab_columns and compared the result. Now I found out the hard way that user_tab_columns is not live but has to be refreshed by analyzing the table ( http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_4462.htm#REFRN26277 ), which I absoultly had no idea of.

describe gets the actual table definition, but doesn't seem to work through perls dbi:Oracle, so I stumbled upon the table_info()and column_info() methods. But where do they get their information from? If they just query *_tab_columns as well, they're not of use to me.

I can't simply test because I didn't manage to pass the right parameters yet. The Dbi Documentation says it is according to the database driver. The Oracle DBD Documentation wasn't very helpfull to me as well, trial and error so far resulted in getting all objects or nothing at all.

At the moment I'm thinking of executing describe via sqlplus through a perl system call and parsing the output....but there has to be a better way.

EDIT:

The view user_tab_columnsworks as expected, if checking the right columns (see comments below ).

like image 500
evilive Avatar asked Sep 29 '22 23:09

evilive


1 Answers

You might have not found the DBD::Oracle documentation particularly helpful, but did you consider using the source code?

Here is the source for table_info() and column_info(). Both subroutines largely seem to be spent building up SQL statements.

like image 141
Dave Cross Avatar answered Oct 18 '22 02:10

Dave Cross