sqlmonetdbrdbms

How to display all columns and its data type in a table via SQL query


I am trying to print the column names from a table called 'meta' and I need also its data types.

I tried this query

SELECT meta FROM INFORMATION_SCHEMA.TABLES;

but it throws an error saying no information schema available. Could you please help me, I am a beginner in SQL.

Edit:

select tables.name from tables join schemas on 
tables.schema_id=schemas.id where schemas.name=’sprl_db’ ;

This query gives me all the tables in database 'sprl_db'


Solution

  • You can use the monetdb catalog:

    select c.name, c.type, c.type_digits, c.type_scale
    from sys.columns c
    inner join sys.tables t on t.id = c.table_id and t.name = 'meta';