Pergunta

É possível inspecionar e, posteriormente, modificar um esquema existente no modo independente do HSQLDB? Tentei olhar para o arquivo usando a ferramenta de administrador embutida, além de conectar o cliente SQL SQL SQL.

Estou particularmente interessado em quais chaves primárias existem em várias tabelas. Existe um comando equivalente ao 'show criativo do mysql ...' ou 'descrever'?

Foi útil?

Solução

o sqltool d O comando aproxima -se de "descrever", e as informações principais primárias são armazenadas no 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)

Outras dicas

O SQLTOOL dt O comando mostrará todos os nomes da tabela e d? O comando mostrará todas as opções 'descrever'.

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top