Home: Perl Programming Help: DBI:
Perl DBI: store the ddl of a column in a variable



db_fan
New User

May 9, 2015, 3:12 PM


Views: 16451
Perl DBI: store the ddl of a column in a variable

Hi,
In Perl DBI, can I store the ddl of a column in a variable? My objective, is to use the definition of the column to create a temp table in another database.

Mike


Zhris
Enthusiast

May 9, 2015, 3:31 PM


Views: 16448
Re: [db_fan] Perl DBI: store the ddl of a column in a variable

Hi,

DBI has a column_info method, as well as similar methods for fetching other schema level data. Of course you can also select this information from the ddl's internal views yourself, the relevant DBD module source should provide useful statements.

Chris


(This post was edited by Zhris on May 9, 2015, 3:42 PM)


db_fan
New User

May 9, 2015, 3:42 PM


Views: 16441
Re: [Zhris] Perl DBI: store the ddl of a column in a variable

Thank you Chris.
What if I have a number of columns? in Perl DBI, I need to create a temp table of those columns and generate a ddl of the temp table on Database A. Then, the DDL of the temp table will be loaded on database B.
Do you have any hints on how to do that?

Mike


Zhris
Enthusiast

May 9, 2015, 3:44 PM


Views: 16440
Re: [db_fan] Perl DBI: store the ddl of a column in a variable

What database driver are you using, MySQL?

Chris


db_fan
New User

May 9, 2015, 3:44 PM


Views: 16438
Re: [Zhris] Perl DBI: store the ddl of a column in a variable

Using DB2

Mike


Zhris
Enthusiast

May 9, 2015, 3:51 PM


Views: 16435
Re: [db_fan] Perl DBI: store the ddl of a column in a variable

I'm not familiar with DB2, have you looked into the syscat tables, specifically the syscat.columns table? It appears you can select all the information you require in one hit off this table.

Apologies, are you stuck on using Perl's DBI module, as oppose to how to get the information as per your original post?

Chris


(This post was edited by Zhris on May 9, 2015, 4:06 PM)