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 Jonathan Eric Miller <je...@uchicago.edu> on 2005/02/10 21:56:42 UTC
Equivlent to MySQL DESCRIBE statement?
Does anyone know if Derby has an equivalent to the MySQL DESCRIBE statement?
In MySQL, you can issue a command like the following to find out the
structure of a table. i.e. list the columns, types, indexes, etc.
DESCRIBE <tableName>;
Jon
Re: Equivlent to MySQL DESCRIBE statement?
Posted by Barnet Wagman <b....@comcast.net>.
The jdbc has facilities for determining structures of tables; see
java.sql.MetaData
E.g. to get field types
DatabaseMetaData meta = con.getMetaData();
ResultSet rc = meta.getColumns(null, null, tableName, "%");
ArrayList names = new ArrayList();
while ( rc.next() ) {
names.add(rc.getString(5)); // 5 = DATA_TYPE
}
MySQL's DESCRIBE is easier, of course, but I've managed to get
everything I need from MetaData
bw
Re: Equivlent to MySQL DESCRIBE statement?
Posted by Jonathan Eric Miller <je...@uchicago.edu>.
It's too bad SQL itself doesn't define a standard command for this
actually...
----- Original Message -----
From: "Lance J. Andersen" <La...@Sun.COM>
To: "Derby Discussion" <de...@db.apache.org>
Sent: Thursday, February 10, 2005 3:48 PM
Subject: Re: Equivlent to MySQL DESCRIBE statement?
> dblook is fine, but it would still be useful to have a command or SQL
> function that is readily available that can be run from ij for example.
> Most people are used to having something like sp_help or describe or show
> to accomplish this from a sql command line interface such as ij.
Re: Equivlent to MySQL DESCRIBE statement?
Posted by Andrew McIntyre <mc...@gmail.com>.
On Thu, 10 Feb 2005 15:52:43 -0600, Jonathan Eric Miller
<je...@uchicago.edu> wrote:
> I'm guessing that at some point there will be UNIX shell scripts/DOS command
> files for commands such as ij, dblook, and starting Derby as a network
> server?
>
> Jon
Hi Jon,
There are currently scripts checked into Subversion. You can view and
download them here:
http://svn.apache.org/viewcvs.cgi/incubator/derby/code/trunk/frameworks/
Scripts for Network Server are in the NetworkServer/bin directory and
scripts for use in embedded mode are in the embedded/bin directory. I
will work on putting them together a new snapshot of the jars so that
they are downloadable from the Derby website.
andrew
Re: Equivlent to MySQL DESCRIBE statement?
Posted by Rajesh Kartha <ka...@Source-Zone.Org>.
Hi,
Meanwhile, here is a SQL that can get the table description;
For example: A table 'ATAB" with schema name 'SAM'
---------------------------------------------------------
ij> create table sam.atab(id int, col1 char(2));
ij> select columnname, columndatatype from sys.syscolumns where
referenceid in (select tableid from sys.systables a,
sys.sysschemas b where a.schemaid=b.schemaid and b.schemaname='SAM' and
a.tablename='ATAB');
COLUMNNAME
|COLUMNDATATYPE
-----------------------------------------------------------------------------------------------------------------------------
-------------------
COL1
|CHAR(2)
ID
|INTEGER
I guess the above can be used in a SQL function, which can then be
executed the normal way ('ij' or java application).
-Rajesh
Jonathan Eric Miller wrote:
> I'm guessing that at some point there will be UNIX shell scripts/DOS
> command files for commands such as ij, dblook, and starting Derby as a
> network server?
>
> Jon
>
> ----- Original Message ----- From: "Lance J. Andersen"
> <La...@Sun.COM>
> To: "Derby Discussion" <de...@db.apache.org>
> Sent: Thursday, February 10, 2005 3:48 PM
> Subject: Re: Equivlent to MySQL DESCRIBE statement?
>
>
>> dblook is fine, but it would still be useful to have a command or SQL
>> function that is readily available that can be run from ij for
>> example. Most people are used to having something like sp_help or
>> describe or show to accomplish this from a sql command line interface
>> such as ij.
>
>
Re: Equivlent to MySQL DESCRIBE statement?
Posted by Jonathan Eric Miller <je...@uchicago.edu>.
I'm guessing that at some point there will be UNIX shell scripts/DOS command
files for commands such as ij, dblook, and starting Derby as a network
server?
Jon
----- Original Message -----
From: "Lance J. Andersen" <La...@Sun.COM>
To: "Derby Discussion" <de...@db.apache.org>
Sent: Thursday, February 10, 2005 3:48 PM
Subject: Re: Equivlent to MySQL DESCRIBE statement?
> dblook is fine, but it would still be useful to have a command or SQL
> function that is readily available that can be run from ij for example.
> Most people are used to having something like sp_help or describe or show
> to accomplish this from a sql command line interface such as ij.
Re: Equivlent to MySQL DESCRIBE statement?
Posted by "Lance J. Andersen" <La...@Sun.COM>.
dblook is fine, but it would still be useful to have a command or SQL
function that is readily available that can be run from ij for example.
Most people are used to having something like sp_help or describe or
show to accomplish this from a sql command line interface such as ij.
Jean T. Anderson wrote:
> Jonathan Eric Miller wrote:
>
>> Does anyone know if Derby has an equivalent to the MySQL DESCRIBE
>> statement? In MySQL, you can issue a command like the following to
>> find out the structure of a table. i.e. list the columns, types,
>> indexes, etc.
>>
>> DESCRIBE <tableName>;
>>
>> Jon
>>
> dblook lets you dump the schema for a database, schema, or a table:
> http://incubator.apache.org/derby/manuals/tools/tools108.html
>
> It'd be easy to write a SQL function to do the same and generate the
> output in whatever format you'd like.
>
> -jean
Re: Equivlent to MySQL DESCRIBE statement?
Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
Jonathan Eric Miller wrote:
> Does anyone know if Derby has an equivalent to the MySQL DESCRIBE
> statement? In MySQL, you can issue a command like the following to
> find out the structure of a table. i.e. list the columns, types,
> indexes, etc.
>
> DESCRIBE <tableName>;
>
> Jon
>
dblook lets you dump the schema for a database, schema, or a table:
http://incubator.apache.org/derby/manuals/tools/tools108.html
It'd be easy to write a SQL function to do the same and generate the
output in whatever format you'd like.
-jean