Get Column Metadata

Column metadata details of a single column of a table in the Catalyst Data Store can be retrieved either by using the columnID or the column name.

Get a Column’s Metadata by ID

You can fetch a column’s meta data of a particular table using get_column_details() method. The datastore_service reference used below is already defined in the component instance page.

    
copy
#Get column's metadata using columnID table_service = datastore_service.table("CITY") column_data = table_service.get_column_details(5249000000032372)

A sample response is shown below :

    
copy
{
table_id: "5249000000011745",
column_sequence: "5",
column_name: "CITYNAME",
category: 2,
data_type: "varchar",
max_length: "100",
is_mandatory: false,
decimal_digits: "2",
is_unique: true,
search_index_enabled: false,
column_id: "5249000000032372"
}

Get a Column’s Metadata by Name

An alternative way to get the meta data of a column is, referring to the column_name. This returns the same response as that of the previous one.

The column meta will not involve any further operations. Therefore, the response is returned here directly. The datastore_service reference used below is already defined in the component instance page.

    
copy
#Get column's metadata using column name table_service = datastore_service.table("CITY") column_data = table_service.get_column_details("CITYNAME")

A sample response is shown below :

    
copy
{
table_id: "5249000000011745",
column_sequence: "5",
column_name: "CITYNAME",
category: 2,
data_type: "varchar",
max_length: "100",
is_mandatory: false,
decimal_digits: "2",
is_unique: true,
search_index_enabled: false,
column_id: "2305000000007725"
}

Get Metadata of All Columns

In addition to getting the meta data of a single column, you can retrieve the meta data of all the columns in a particular table using get_all_columns() method. The datastore_service reference used below is already defined in the component instance page.

    
copy
#Get metadata of all columns table_service = datastore_service.table("CITY") columns = table_service.get_all_columns()

A sample response is shown below :

    
copy
[
{
table_id: "5249000000011745",
column_sequence: "1",
column_name: "ROWID",
category: 1,
data_type: "bigint",
max_length: "50",
is_mandatory: false,
decimal_digits: "2",
is_unique: false,
search_index_enabled: false,
column_id: "2136000000007784"
},
{
table_id: "5249000000011745",
column_sequence: "2",
column_name: "CREATORID",
category: 1,
data_type: "bigint",
max_length: "50",
is_mandatory: false,
decimal_digits: "2",
is_unique: false,
search_index_enabled: true,
column_id: "2136000000007785"
},
{
table_id: "5249000000011745",
column_sequence: "3",
column_name: "CREATEDTIME",
category: 1,
data_type: "datetime",
max_length: "50",
is_mandatory: false,
decimal_digits: "2",
is_unique: false,
search_index_enabled: true,
column_id: "2136000000007786"
},
{
table_id: "5249000000011745",
column_sequence: "4",
column_name: "MODIFIEDTIME",
category: 1,
data_type: "datetime",
max_length: "50",
is_mandatory: false,
decimal_digits: "2",
is_unique: false,
search_index_enabled: true,
column_id: "2136000000007787"
},
{
table_id: "5249000000011745",
column_sequence: "5",
column_name: "CITYNAME",
category: 2,
data_type: "varchar",
max_length: "100",
is_mandatory: false,
decimal_digits: "2",
is_unique: true,
search_index_enabled: true,
column_id: "2136000000008588"
}
]

Last Updated 2023-12-18 16:20:08 +0530 +0530

ON THIS PAGE
ACCESS THIS PAGE