我想通过在 Teradata 中运行查询将列名导出到 Excel 工作表中。我用了ctrl+c,但是没用。提前致谢。
问问题
4644 次
4 回答
1
在 Result Set View Preferences\Copy Options\ 中更改您的设置,选中“Copy Include Column Headers”
“结果集视图首选项”是结果集视图窗口上看起来像钳子的第一个按钮。
于 2018-03-23T19:52:32.790 回答
0
我找到了答案show table tablename
于 2018-02-15T13:14:39.410 回答
0
要获取列名,请打开您的答案集,然后保存结果集。文件 > 另存为 >
于 2018-02-15T12:51:50.933 回答
0
我经常想报告列,而 dbc.columns 是最好的方法。它们都带有正确的填充物,因此修剪使它们可以很好地粘贴到 Excel 中。我还添加了一个 case 语句,它将为您翻译数据类型。
sel
trim(databasename)
, trim(tablename)
, trim(columnname)
, max(case
when columntype = 'D' then 'decimal(' || decimaltotaldigits || ', ' || decimalfractionaldigits || ')'
when columntype = 'CV' then 'varchar(' || columnlength || ')'
when columntype = 'CF' then 'char(' || columnlength || ')'
when columntype like 'I%' then 'integer'
else 'unknown' end) as colDDL
from dbc.columns where tablename in (<sometableList>)
and databasename in (<someDBList>)
order by column_id
DBC.columns 数据映射示例的完整列表:
create volatile table vt_woe_col_list
as (
select
trim(columnname) as column_name
, case when ColumnType in ('CF','CV') then 'Character'
when ColumnType in ('D','F','I1','I2','I') then 'Numeric'
when ColumnType in ('DA') then 'Date'
when ColumnType in ('SZ','TS') then 'TimeStamp'
else 'Skip' end as process_type
, case trim(columntype)
when 'AT' then 'TIME'
when 'BF' then 'BYTE'
when 'BO' then 'BLOB'
when 'BV' then 'VARBYTE'
when 'CF' then 'CHAR'
when 'CO' then 'CLOB'
when 'CV' then 'VARCHAR'
when 'D' then 'DECIMAL'
when 'DA' then 'DATE'
when 'DH' then 'INTERVAL DAY TO HOUR'
when 'DM' then 'INTERVAL DAY TO MINUTE'
when 'DS' then 'INTERVAL DAY TO SECOND'
when 'DY' then 'INTERVAL DAY'
when 'F' then 'FLOAT'
when 'GF' then 'GRAPHIC'
when 'GV' then 'VARGRAPHIC'
when 'HM' then 'INTERVAL HOUR TO MINUTE'
when 'HR' then 'INTERVAL HOUR'
when 'HS' then 'INTERVAL HOUR TO SECOND'
when 'I1' then 'BYTEINT'
when 'I2' then 'SMALLINT'
when 'I' then 'INTEGER'
when 'MI' then 'INTERVAL MINUTE'
when 'MO' then 'INTERVAL MONTH'
when 'MS' then 'INTERVAL MINUTE TO SECOND'
when 'SC' then 'INTERVAL SECOND'
when 'SZ' then 'TIMESTAMP WITH TIME ZONE'
when 'TS' then 'TIMESTAMP'
when 'TZ' then 'TIME WITH TIME ZONE'
when 'YM' then 'INTERVAL YEARTO MONTH'
when 'YR' then 'INTERVAL YEAR'
when 'UT' then 'UDT Type'
end as column_type_desc
, a.*
from dbc.columns A
where trim(tablename )='t_woe_data_samp'
and trim(databasename)= 'DUCSMAD'
) with data
primary index(column_name)
on commit preserve rows;
于 2018-02-17T02:09:29.940 回答