You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Nik <ni...@gmail.com> on 2007/12/28 12:09:22 UTC

Howto get existing table names

Hi, I apologize if this is too simple a question.  I'm tring to make a  
statement to return all the tables in the database.  I haven't been able  
to find how to do this yet.  I was trying to use DataBaseMetaData, but the  
method seems to require the table names.  Thank you in advance.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Re: Howto get existing table names

Posted by Raymond Kroeker <ra...@raykroeker.com>.
>From the class documentation of DatabaseMetaData (JDK 6):
"If a search pattern  argument is set to <code>null</code>, that argument's
criterion will  be dropped from the search."

Raymond

On Dec 28, 2007 9:44 AM, Mark Thornton <mt...@optrak.co.uk> wrote:

> Raymond Kroeker wrote:
> > I've also found that passing null also includes all tables.
> >
> It might do, but as the documentation for DatabaseMetaData.getTables
> doesn't define what happens for a null tableNamePattern argument, it
> would be better not to rely on this. Odd though given that null is
> explicitly mentioned for all the other parameters. I seem to remember
> that some JDBC drivers throw an exception if you use a null
> tableNamePattern parameter.
>
> Mark Thornton
>
>


-- 
---------------------------------------------------------
Raymond Kroeker

Re: Howto get existing table names

Posted by Mark Thornton <mt...@optrak.co.uk>.
Raymond Kroeker wrote:
> I've also found that passing null also includes all tables.
>
It might do, but as the documentation for DatabaseMetaData.getTables 
doesn't define what happens for a null tableNamePattern argument, it 
would be better not to rely on this. Odd though given that null is 
explicitly mentioned for all the other parameters. I seem to remember 
that some JDBC drivers throw an exception if you use a null 
tableNamePattern parameter.

Mark Thornton


Re: Howto get existing table names

Posted by Raymond Kroeker <ra...@raykroeker.com>.
I've also found that passing null also includes all tables.

Raymond

On Dec 28, 2007 3:09 AM, Nik <ni...@gmail.com> wrote:

> Hi, I apologize if this is too simple a question.  I'm tring to make a
> statement to return all the tables in the database.  I haven't been able
> to find how to do this yet.  I was trying to use DataBaseMetaData, but the
> method seems to require the table names.  Thank you in advance.
>
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
>



-- 
---------------------------------------------------------
Raymond Kroeker

RE: Howto get existing table names

Posted by "Thomas J. Taylor" <Th...@Miami.edu>.
Try passing a NULL under the 'TABLE_NAME' parameter to the
DatabaseMeataData. That should return all table names.

-----Original Message-----
From: Nik [mailto:nicholas.tripp@gmail.com] 
Sent: Friday, December 28, 2007 6:09 AM
To: derby-user@db.apache.org
Subject: Howto get existing table names

Hi, I apologize if this is too simple a question.  I'm tring to make a  
statement to return all the tables in the database.  I haven't been able  
to find how to do this yet.  I was trying to use DataBaseMetaData, but the  
method seems to require the table names.  Thank you in advance.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/



Re: Howto get existing table names

Posted by Nik <ni...@gmail.com>.
Actually what I've done is this:
String[] types = {"TABLE"};
         ResultSet resultSet = dbmd.getTables(null, null, "%", types);
I then cycle the result with a while loop and rs.next(). Thanks for  
everyone's responses.
On Mon, 31 Dec 2007 12:34:57 +0900, Jitesh <ji...@pramati.com> wrote:

> select TABLENAME from SYS.SYSTABLES where TABLETYPE='T'
>
> Doesn't this work for you ?
>
> Jitesh
>
> ----- Original Message ----- From: "Nik" <ni...@gmail.com>
> To: <de...@db.apache.org>
> Sent: Friday, December 28, 2007 4:39 PM
> Subject: Howto get existing table names
>
>
>> Hi, I apologize if this is too simple a question.  I'm tring to make a  
>> statement to return all the tables in the database.  I haven't been  
>> able to find how to do this yet.  I was trying to use DataBaseMetaData,  
>> but the method seems to require the table names.  Thank you in advance.
>>
>> -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
>



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Re: Howto get existing table names

Posted by Jitesh <ji...@pramati.com>.
select TABLENAME from SYS.SYSTABLES where TABLETYPE='T'

Doesn't this work for you ?

Jitesh

----- Original Message ----- 
From: "Nik" <ni...@gmail.com>
To: <de...@db.apache.org>
Sent: Friday, December 28, 2007 4:39 PM
Subject: Howto get existing table names


> Hi, I apologize if this is too simple a question.  I'm tring to make a 
> statement to return all the tables in the database.  I haven't been able 
> to find how to do this yet.  I was trying to use DataBaseMetaData, but the 
> method seems to require the table names.  Thank you in advance.
>
> -- 
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ 


Re: Howto get existing table names

Posted by Mark Thornton <mt...@optrak.co.uk>.
Nik wrote:
> Hi, I apologize if this is too simple a question.  I'm tring to make a 
> statement to return all the tables in the database.  I haven't been 
> able to find how to do this yet.  I was trying to use 
> DataBaseMetaData, but the method seems to require the table names.  
> Thank you in advance.
>
Supply "%" as the tablename (match anything).