The TableMetaData object can be used to obtain information about an specific table and it's columns.

1 Get table metadata

You can obtain a TableMetaData object from connection by table name.

Copy
<script>
    var md = Ax.db.getMetaData().getTableMetaData("systables");
    console.log("    NRows: " + md.getRowCount());
    console.log("    NCols: " + md.getColumnCount());
    console.log(" ColNames: " + md.getColumnNames());
</script>
NRows: 137
    NCols: 26
 ColNames: [tabname, owner, partnum, tabid, rowsize, ncols, nindexes, nrows, created, version, tabtype, locklevel, npused, fextsize, nextsize, flags, site, dbname, type_xid, am_id, pagesize, ustlowts, secpolicyid, protgranularity, statchange, statlevel]

2 Column meta data

The following example shows how to get column metadata.

Copy
<script>
    var refresh = false;
    Ax.db.execute("DROP TABLE IF EXISTS t1 ");    
    Ax.db.execute("CREATE TABLE t1 (a DECIMAL(12, 3) DEFAULT 10.2 NOT NULL, b VARCHAR(20))");    
    var md = Ax.db.getMetaData().getTableMetaData("t1", refresh);
    for  (var columnName of md.getColumnNames()) {
        console.log("      Name: " + columnName);
        console.log("      Size: " + md.getColumnSize(columnName));
        console.log("     Scale: " + md.getColumnScale(columnName));
        console.log(" Precision: " + md.getColumnPrecision(columnName));
        console.log("   Default: " + md.getColumnDefault(columnName));
        console.log("  Nullable: " + md.isColumnNullable(columnName));
    }
</script>
Name: a
      Size: 12
     Scale: 3
 Precision: 12
   Default: 10,2000000000
  Nullable: false
  
      Name: b
      Size: 20
     Scale: 0
 Precision: 20
   Default: null
  Nullable: true