Page 1 of 1

[Solved] Exporting a list of tables and fields

Posted: Mon Jun 24, 2024 10:25 am
by Yumi
I would like to export a list of all the tables and the field-names they contain, no data. Could be as .csv or .ods or else. Is this possible?

Re: Exporting a list of tables and fields

Posted: Mon Jun 24, 2024 5:07 pm
by Sliderule
You have not told us in this post, which database backend you are using . . . therefore . . . I will assume you are using HSQL.

You can create a Query as defined below . . . and . . . since you have a registered database ( I presume ), import it to Calc . . . and / or . . . save it as a CSV, or, ODS file.

Code: Select all

Select 
   SYS_TABLES."TABLE_TYPE" as "TABLE or VIEW", 
   '"' || SYS_TABLES."TABLE_NAME" || '"' as "TABLE NAME", 
   SYS_COLUMNS."ORDINAL_POSITION" as "COLUMN POSITION", 
   '"' || SYS_COLUMNS."COLUMN_NAME" || '"' as "COLUMN NAME", 
   SYS_COLUMNS."TYPE_NAME" as "TYPE NAME", 
   SYS_COLUMNS."COLUMN_SIZE" as "COLUMN SIZE" 
From "INFORMATION_SCHEMA"."SYSTEM_TABLES" as SYS_TABLES, 
     "INFORMATION_SCHEMA"."SYSTEM_COLUMNS" as SYS_COLUMNS 
Where SYS_TABLES."TABLE_SCHEM" = 'PUBLIC' 
  and SYS_TABLES."TABLE_TYPE" IN ( 'TABLE', 'VIEW') 
  and SYS_TABLES."TABLE_NAME" = SYS_COLUMNS."TABLE_NAME" 
Order By SYS_TABLES."TABLE_TYPE", 
         '"' || SYS_TABLES."TABLE_NAME" || '"', 
         SYS_COLUMNS."ORDINAL_POSITION"
I hope this helps, please be sure to let me / us know.

Sliderule

Thanks to add [Solved] in your 1st post Subject (edit button top right) if this issue has been resolved.

Re: Exporting a list of tables and fields

Posted: Tue Jun 25, 2024 4:40 am
by Yumi
It works without any modifications. Thanks for this advice and sorry to rely on your assumptions. It will help to bring different databases together and create a overview.

Re: Exporting a list of tables and fields

Posted: Tue Jun 25, 2024 2:32 pm
by Bidouille
Sliderule wrote: Mon Jun 24, 2024 5:07 pmYou can create a Query as defined below . . . and . . . since you have a registered database ( I presume ), import it to Calc . . . and / or . . . save it as a CSV, or, ODS file.
With this OXT, the export in CSV made easy :)

Re: [Solved] Exporting a list of tables and fields

Posted: Wed Jun 26, 2024 2:40 pm
by Sliderule
Bidouille:

Thanks for your suggestion of OXT extension.

I am sending you a PM ( Private Message ) .

Sliderule