db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satheesh Bandaram <sathe...@Sourcery.Org>
Subject Re: Equivlent to MySQL DESCRIBE statement?
Date Thu, 10 Feb 2005 22:05:52 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
You can write a simple query, joining syscolumns and systables, as
follows:<br>
<br>
ij&gt; create table test(i int, f float, c char(20), v varchar(255), b
varchar(10) for bit data);<br>
0 rows inserted/updated/deleted<br>
ij&gt; select cast(c.columnname as varchar(20)) columnname,
c.columnnumber, c.columndatatype<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from sys.syscolumns c where referenceid
in (select tableid
from sys.systables t,sys.sysschemas s<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;&nbsp; where tablename='TEST' and
s.schemaid=t.schemaid and schemaname='APP');<br>
COLUMNNAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|COLUMNNUMB&amp;|COLUMNDATATYPE<br>
------------------------------------------------<br>
B&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|VARCHAR (10) F&amp;<br>
C&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|CHAR(20)<br>
F&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|DOUBLE<br>
I&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; |1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|INTEGER<br>
V&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|VARCHAR(255)<br>
<br>
5 rows selected<br>
<br>
It is possible to put the query in a view or a procedure and get
required values from there. Of course, it would be easier if Derby were
providing using a statement like DESCRIBE, but each database vendor
seems to have their own way here.<br>
<br>
Satheesh<br>
<br>
Bernd Ruehlicke wrote:
<blockquote
 cite="mid1B37BEFB3456F1428E01932AFA147822E1A3CE@HOUEXCH902.landmark.lgc.com"
 type="cite">
  <pre wrap="">Add a JIRA
(<a class="moz-txt-link-freetext" href="http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10594">http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10594</a>)
to
the Derby and let people vote for it.

B-) 

  </pre>
  <blockquote type="cite">
    <pre wrap="">-----Original Message-----
From: Jonathan Eric Miller [<a class="moz-txt-link-freetext" href="mailto:jemiller@uchicago.edu">mailto:jemiller@uchicago.edu</a>]

Sent: Thursday, February 10, 2005 2:57 PM
To: Derby User List
Subject: 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 &lt;tableName&gt;;

Jon


    </pre>
  </blockquote>
  <pre wrap=""><!---->

  </pre>
</blockquote>
</body>
</html>

Mime
View raw message