Pregunta

¿Es posible inspeccionar y posteriormente modificar un esquema existente en modo autónomo hsqldb? He intentado buscar en el archivo con el construido en la herramienta de administración, así como conectar Cliente SQuirreL SQL.

Estoy particularmente interesado en lo que existen las claves principales en varias tablas. ¿Hay comando equivalente a la de MySQL SHOW CREATE TABLE ... 'o 'describir'?

¿Fue útil?

Solución

El sqltool \ d se aproxima a un comando "describir", y la información de clave principal se almacena bajo la INFORMATION_SCHEMA:

sql> CREATE SCHEMA STACKOVERFLOW;
sql> SET SCHEMA STACKOVERFLOW;
sql> CREATE TABLE SO2406470 (pk1 INT NOT NULL, pk2 INT NOT NULL, data VARCHAR(64), PRIMARY KEY(pk1, pk2));
sql> \d SO2406470
name  datatype  width  no-nulls
----  --------  -----  --------
PK1   INTEGER      11  *
PK2   INTEGER      11  *
DATA  VARCHAR      64  
sql> SELECT * FROM INFORMATION_SCHEMA.SYSTEM_PRIMARYKEYS WHERE TABLE_SCHEM = CURRENT_SCHEMA AND TABLE_NAME = 'SO2406470';
TABLE_CAT  TABLE_SCHEM    TABLE_NAME  COLUMN_NAME  KEY_SEQ  PK_NAME
---------  -------------  ----------  -----------  -------  ------------
PUBLIC     STACKOVERFLOW  SO2406470   PK1                1  SYS_PK_10040
PUBLIC     STACKOVERFLOW  SO2406470   PK2                2  SYS_PK_10040

Fetched 2 rows

(hsqldb-2.0.0rc9)

Otros consejos

El SQLtool \ dt comando mostrará todos los nombres de tabla y \ d? comando mostrará todos 'describir' opciones.

sql> \dt
TABLE_SCHEM  TABLE_NAME
-----------  ---------------
PUBLIC       APP_CFG
PUBLIC       CFG_REFRESH_LOG
...
sql> \d?
\dX [parameter...] where X is one of the following.
    a:  list Aliases
    c:  list Catalogs
    i:  list Indexes (for some databases, must specify literal target table)
    n:  list schema Names
    r:  list Roles
    s:  list Sequences
    S:  list System tables
    t:  list Tables
    u:  list Users
    v:  list Views
    *:  list table-like objects
    ...
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top