query sysmaster tables for index information
Posted in 2000
Topics: General Discussion
Any recommendations on how I might query sysmaster tables to reconstruct index build commands in SQL? (or is this even possible?) My initial search through the sysmaster and user sys___ tables did not succeed. Thanks for the help. Ben
Ben Draper wrote:
>
> Any recommendations on how I might query sysmaster tables to reconstruct
> index build commands in SQL? (or is this even possible?)
>
> My initial search through the sysmaster and user sys___ tables did not
> succeed.
DDL statements, like CREATE INDEX, are more easily reconstructed using the
system catalog tables in the individual databases. Index information is
gleaned from the sysindexes table which contains the column numbers of the
columns making up the key in order (time -1 if a descending column in the
key). But isn't it easier to just use dbschema (or myschema) and parse out
the CREATE INDEX commands you are interested in using awk or perl? Try
this simple awk script:
#
# Script: extract_indexes.awk
#
BEGIN {in_index=0;}
# For myschema make the matching text line upper case
/create index/ {in_index=1;}
# Also the above line is simplistic you have to allow for the unique,
# distinct, and cluster keywords also for a 'real' script.
{
if (in_index) {
print $0;
}
next;
}
/";"/ {in_index=0'}
dbschema -d mydatabase | awk -f extract_indexes.awk
Art S. Kagel