SQL/MX 3.2 Management Manual (H06.25+, J06.14+)

Table Of Contents
>> set schema samdbcat.definition_schema_version_<schema version>;
--- SQL operation complete.
>> select substring(c.column_name, 1, 25) as column_name,
c.column_number as base_table_column,
ac.system_added_column
from access_paths ap, access_path_cols ac, cols c, objects o
where
ap.access_path_uid = o.object_uid
and ap.access_path_uid <> ap.table_uid
and c.object_uid = ap.table_uid
and o.object_name = 'XCUSTNAM'
and ac.column_number = c.column_number
and ac.access_path_uid = ap.access_path_uid
and o.schema_uid =
(select schema_uid
from nonstop_sqlmx_<sys name>.system_schema.schemata
where
schema_name = 'SALES' and
cat_uid =
(select cat_uid
from nonstop_sqlmx_<sys name>.system_schema.catsys
where cat_name = 'SAMDBCAT'
)
)
for read uncommitted access;
SYSTEM_ADDED_COLUMN
-------------------
BASE_TABLE_COLUMN
-----------------
COLUMN_NAME
-----------------------
Y
N
0
1
CUSTNUM
CUSTNAME
Displaying all Columns in a Primary Key or Unique Constraint
This example displays all columns with primary key or unique constraints for the table
SAMDBCAT.SALES.ODETAIL; two columns of this table make up the primary key:
>> set schema samdbcat.definition_schema_version_<schema version>;
>> select substring(c.column_name, 1, 15) as column_name,
c.column_number as col_num,
case t.constraint_type
when 'C' then 'CHECK'
when 'F' then 'FOREIGN'
when 'P' then 'PRIMARY KEY'
when 'U' then 'UNIQUE'
else 'UNKNOWN'
end as type,
substring(o2.object_name , 1, 24) as constraint_name
from cols c,
objects o1,
objects o2,
key_col_usage k,
tbl_constraints t
where c.object_uid = t.table_uid
and k.constraint_uid = t.constraint_uid
and k.column_number = c.column_number
and t.table_uid = o1.object_uid
and o1.object_name = 'ODETAIL'
and o2.object_uid = t.constraint_uid
and o1.schema_uid =
(select schema_uid from
nonstop_sqlmx_<sys name>.system_schema.schemata s
where s.schema_name = 'SALES' and
140 Querying SQL/MX Metadata