更新时间:2023-11-07 21:24:04
较新版本的 Teradata 支持 NPath
,可用于此目的.你必须习惯语法,它是一个表运算符 :-)
Newer versions of Teradata support NPath
, which can be used for this. You have to get used to the syntax, it's a Table Operator :-)
例如这将返回系统中每个表的列列表:
E.g. this returns the column list for each table in your system:
SELECT *
FROM
NPath(ON(SELECT databasename, tablename, columnname, columnid
FROM dbc.columnsV
) AS dt -- input data
PARTITION BY databasename, tablename -- group by columns
ORDER BY columnid -- order within list
USING
MODE (NonOverlapping) -- required syntax
Symbols (True AS F) -- every row
Pattern ('F*') -- is returned
RESULT(First (databasename OF F) AS DatabaseName, -- group by column
First (tablename OF F) AS TableName, -- group by column
Count (* OF F) AS Cnt,
Accumulate(Translate(columnname USING unicode_to_latin) OF ANY (F)) AS ListAgg
)
);
应该比 XMLAgg 好.
Should be waaaaaay better than XMLAgg.