KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Getting List of Tables
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: January 16, 2020

There are multiple ways to get a list of tables in the database however there are some caveats to some of them.

The examples will be based on the following structure:

Table_1 is a normal table with a Primary Key
Table_2 is an invisible table with a Primary Key
Table_3 is a normal table without a Primary Key


The easiest way to get a list of tables is the GET TABLE TITLES command. This will populate two arrays with the names and table numbers for each table. However, it does not show any invisible tables.

For Example:

GET TABLE TITLES($arrTableName;$arrTableNum)
will return only the following two tables:


Viewing the DataStore with the ds command. This will show the tables in object notation that can be stored in an object type variable. The limitation of this command is that only tables with a Primary Key will show up in the DataStore.

For Example:
ds
will return only the following two tables:


The safest way to view all tables regardless of it's settings is to use SQL and access the 4D System Tables. The system tables will list all of the tables in the database however SQL needs to be used to access the data.

For Example:
Begin SQL
  SELECT TABLE_NAME
  FROM _USER_TABLES
  INTO :arrTableNames

End SQL

will return all three tables: