Is there an HSQLDB equivalent for the MYSQL SHOW COLUMNS from TABLE command?
HSQLDB does not have separate commands for showing tables, columns or other database objects.
You use SELECT * FROM INFORMATION_SCHEMA.COLUMNS and various other tables in the INFORMATION_SCHEMA for such purposes.
http://hsqldb.org/doc/2.0/guide/databaseobjects-chapt.html#dbc_information_schema
This is the query that you need.
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '<your schema>' AND TABLE_NAME = '<name table or view>';
Related
I'm using this query to shows table from a schema in h2, but it's not working
enter image description here
The SHOW command does not implement complex filtering conditions. However, you can run a simple SELECT to get your tables:
select table_name
from information_schema.tables
where table_schema = 'PUBLIC' -- your schema
and table_type = 'TABLE'
and table_name like '%RU%' -- your custom filtering condition
Oracle has a query that selects the existing indexes of a table.
For example:
SELECT * FROM user_indexes WHERE table_name = 'CM_WCEL';
But I need to recreate the index creation statement.
How can I get the remaining information like the affected columns, etc?
To get the complete DDL for each index, use dbms_metadata.get_ddl():
select index_name, dbms_metadata.get_ddl('INDEX', index_name) as ddl
from user_indexes
where table_name = CM_WCEL';
The DDL is returned as a CLOB. Depending on the SQL client you are using you might need some configuration changes to be able to see the complete code. e.g. in SQL*Plus you need something set long 60000 before you run the select statement.
As per the creation of table, the below tables will have the requested information.
SELECT *
FROM user_ind_columns
WHERE table_name = 'CM_WCEL';
or
SELECT *
FROM dba_ind_columns
WHERE table_name = 'CM_WCEL';
this should provide needed information:
select index_name, column_name
from user_ind_columns
where table_name = 'CM_WCEL';
There are several tables with many columns and it takes forever to manually find the column I need. How do I search for my column from whatever table it exists in?
You can do:
SELECT COLUMN_NAME, TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%columnName%'
You can use the sys.columns view and then join to the sys.tables view to get that information.
Is there any command that I can locate a certain table from all databases? Since I forgot where the table is. Thanks.
Use the MySQL specific:
SHOW TABLES
...or use the ANSI standard, INFORMATION_SCHEMA.TABLES:
SELECT table_name,
table_schema AS dbname
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name='searched table name'
I want to write a program that can show the user a list of tables in the database and also show the descriptions of those tables. So can I do a "select * from system_table" or something like that?
This will give you a list of tables:
show tables;
To describe each table:
describe table_name;
To get both at the same time try:
SELECT * FROM DOMAIN.TABLES WHERE TYPE = 'TABLE'
SELECT * FROM DOMAIN.COLUMNS WHERE TABLETYPE = 'TABLE'
The results are similar to MySql show and describe statements
In addition to show tables, MySQL 5.0+ also supports the INFORMATION_SCHEMA meta-database:
SELECT table_name, table_comment FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'db_name';
information_schema.tables also has other information in it, if you're curious.
Note that if you didn't provide a comment when you created the table and use InnoDB, it will fill the table_comment column with unnecessary data, such as the InnoDB space reserved for this table or the foreign key constraints.