|
|
Archives of the TeradataForum
Message Posted: Thu, 12 Jan 2012 @ 19:54:25 GMT
Subj: | | Re: Generate collect statistics statement |
|
From: | | HPadarthi |
select
(case Min_Pos
when 1 then 'Collect Statistics on ' ||
trim(upper(DatabaseName)) || '.' ||
trim(upper(TableName)) || ' INDEX ('
else ' ,' end) ||
trim(upper(ColumnName)) ||
(case Max_Pos
when 1 then ');'
else '' end) (TITLE '')
from
(
select
DatabaseName,
TableName,
ColumnName,
IndexNumber,
ColumnPosition,
rank() over (partition by DatabaseName, TableName, IndexNumber order by ColumnPosition)
Min_Pos,
rank() over (partition by DatabaseName, TableName, IndexNumber order by ColumnPosition desc) Max_Pos
from
dbc.Indices
where
DatabaseName = 'databasename' and
TableName like 'abc%'
) xxx
order by
DatabaseName, TableName, IndexNumber, ColumnPosition; ng it from your computer.
| |