SELECT T1.TABLE_NAME ,LISTAGG(CASE WHEN T2.DATA_TYPE = ‘DATE‘ THEN ‘TO_CHAR(‘||T1.COLUMN_NAME || ‘,‘‘YYYYMMDD‘‘)‘ ELSE T1.COLUMN_NAME END,‘||‘‘|‘‘||‘)WITHIN GROUP(ORDER BY T1.COLUMN_NAME) AS KEY_NAMES FROM USER_CONS_COLUMNS T1 JOIN USER_TAB_COLUMNS T2 ON T1.TABLE_NAME = T2.TABLE_NAME AND T1.COLUMN_NAME = T2.COLUMN_NAME WHERE T1.POSITION IS NOT NULL AND T1.TABLE_NAME = ‘""" + table_name + """‘ GROUP BY T1.TABLE_NAME