Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 12 Jan 2012 @ 20:43:59 GMT


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


Subj:   Re: Generate collect statistics statement
 
From:   DAVID WILLIAMS

     sel CASE WHEN MAX_POSITION = MIN_POSITION
                            THEN 'COLLECT STATS '  ||  TRIM(A.DATABASENAME) || '.' ||
     TRIM(A.TABLENAME) || ' INDEX  (' || TRIM(COLUMNNAME) || ');'
                            WHEN COLUMNPOSITION = MIN_POSITION
                             THEN 'COLLECT STATS ' || TRIM(A.DATABASENAME) || '.' ||
     TRIM(A.TABLENAME) || ' INDEX (' || TRIM(COLUMNNAME) || ','
                            WHEN COLUMNPOSITION = MAX_POSITION
                            THEN  TRIM(COLUMNNAME) || ');'
                            ELSE TRIM(COLUMNNAME) || ','
              END   (title '')
      from dbc.indices a,
                (sel databasename,
                         tablename,
                         indextype,
                         indexnumber,
                         max(columnposition) AS MAX_POSITION,
                         min(columnposition)  AS MIN_POSITION
                 from dbc.indices
                   GROUP BY 1,2,3,4) b
     where A.databasename = :dname
       ---    and A.tablename = :tname
         AND A.DATABASENAME = B.DATABASENAME
         AND A.TABLENAME = B.TABLENAME
         and a.indextype = b.indextype
         and a.indexnumber= b.indexnumber
         ORDER BY  A.DATABASENAME, A.TABLENAME,A.INDEXNUMBER,A.INDEXTYPE,COLUMNPOSITION;


     
  <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: 27 Dec 2016