Re: Duplicate table structure
On Thu, 07 Jun 2007 08:47:00 +0200, Dr.Ruud wrote: Peter Scott schreef: Is there a simple way to create a new table with the same structure as a given one in a *different* database? That means the CREATE TABLE foo AS SELECT * FROM bar WHERE 1=2 method won't work. I'd need to have two database handles open. They're both Oracle I suppose the DBD can give you enough information on the table to generate a CREATE statement from that. Yes, it does. I ended up taking the output of DESCRIBE and tweaking it a little. I was just using the opportunity to wonder if there was an even lazier way. The suggestion of another poster to use dbms_metadata (see, e.g. http://builder.com.com/5100-6388-5054021.html) was a good one; I'd not heard of it before. If I have to do more than just column type definitions, or multiple tables, in the future, I'll definitely check it out. -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/
Re: Duplicate table structure
On 6/8/07, Peter Scott [EMAIL PROTECTED] wrote: The suggestion of another poster to use dbms_metadata (see, e.g. http://builder.com.com/5100-6388-5054021.html) was a good one; I'd not heard of it before. If I have to do more than just column type definitions, or multiple tables, in the future, I'll definitely check it out. dbms_metadata has one nasty flaw - the output must be manually reformatted to be usable. Try using DDL::Oracle, as it does work. -- Jared Still Certifiable Oracle DBA and Part Time Perl Evangelist
Re: Duplicate table structure
Peter Scott schreef: Is there a simple way to create a new table with the same structure as a given one in a *different* database? That means the CREATE TABLE foo AS SELECT * FROM bar WHERE 1=2 method won't work. That instruction doesn't guarantee that the new table has the same structure. (for some definition of structure) I'd need to have two database handles open. They're both Oracle I suppose the DBD can give you enough information on the table to generate a CREATE statement from that. -- Affijn, Ruud Gewoon is een tijger.