Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 12 Jan 2012 @ 19:54:25 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


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.


     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023