📄 oracletool.pl
字号:
# If not set, default to '2'. $menufontsize = $expire; # $statement_id holds the value for TEXTAREA width $textarea_w = $statement_id; # $user holds the value for TEXTAREA height $textarea_h = $user; # $whereclause holds the value for how many rows to display. $rowdisplay = $whereclause; $properties = "$schema_cols%$fontsize%$menufontsize%$textarea_w%$textarea_h%$rowdisplay"; $path = dirname($scriptname); $cookie = cookie(-name=>"OracletoolProps",-value=>"$properties",-path=>"$path",-expires=>"+10y"); print header(-cookie=>[$cookie]); $message = "Your personal Oracletool preferences have been updated.<BR>Oracletool will restart with a connection to instance $database."; $duration = "4"; $url = "$scriptname?database=$database&object_type=FRAMEPAGE"; $bgline = "<BODY BGCOLOR=$bgcolor>\n"; if ($bgimage) { if ((-e "$ENV{'DOCUMENT_ROOT'}/$bgimage") && (-r "$ENV{'DOCUMENT_ROOT'}/$bgimage")) { logit(" Background image is $ENV{'DOCUMENT_ROOT'}/$bgimage and is readable"); $bgline = "<BODY BACKGROUND=$bgimage>\n"; } } print <<"EOF";<HTML> <HEAD> <TITLE>Properties have been reset.</TITLE> <META HTTP-EQUIV="Refresh" Content="$duration;URL=$url"> </HEAD> $bgline <FONT FACE="$font" SIZE="$fontsize" COLOR="$fontcolor"> <CENTER> $message </CENTER </BODY</HTML>EOF logit("Exit subroutine setProperties"); exit;}sub showProps { logit("Enter subroutine showProps"); # Display a menu for selecting non-default properties for the tool. # These will be stored as cookies. message("Oracletool preferences<BR>Setting these values will override values set in any theme.<BR>Submit changes or select theme at the bottom of this screen."); my ($fontsizeoverride,$fontoverride,$val); print <<"EOF";<FORM METHOD="POST" ACTION="$scriptname" TARGET="_top"><TABLE BORDER=0 ALIGN=LEFT> <TR WIDTH=50%> <TD ALIGN=CENTER> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <INPUT TYPE=HIDDEN NAME='database' VALUE='$database'> <INPUT TYPE=HIDDEN NAME='object_type' VALUE='SETPROPS'> <INPUT TYPE=SUBMIT NAME='foobar' VALUE='Submit changes'> </TD> </TR> <TR> <TD VALIGN="TOP"> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <B> Schema list column number:<BR> This sets the number of columns in the schema list table.<BR>EOF # Loop through the values, in order to check the box which is the # value of what is set now. foreach $val ('3','4','5','6','7') { print " <INPUT TYPE=RADIO NAME='schema' VALUE='$val'"; if ($val == $schema_cols) { print " CHECKED>$val\n"; } else { print " >$val\n"; } }print <<"EOF"; <HR WIDTH='50%' ALIGN='LEFT'> </TD> </TR> <TR> <TD VALIGN="TOP"> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <B> Font size override:<BR> This will override the font size set by your theme.<BR>EOF # Loop through the values, in order to check the box which is the # value of what is set now. foreach $val ('1','2','3','4','5','6','7') { print "<INPUT TYPE=RADIO NAME='explainschema' VALUE='$val'"; if ($val == $fontsize) { print " CHECKED>$val\n"; } else { print " >$val\n"; } }print <<"EOF"; <HR WIDTH='50%' ALIGN='LEFT'> </TD> </TR> <TR> <TD VALIGN="TOP"> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <B> Menu button font size override:<BR> This will override the menu button font size set by your theme.<BR>EOF # Loop through the values, in order to check the box which is the # value of what is set now. foreach $val ('1','2','3','4') { print "<INPUT TYPE=RADIO NAME='expire' VALUE='$val'"; if ($val == $menufontsize) { print " CHECKED>$val\n"; } else { print " >$val\n"; } }print <<"EOF"; <HR WIDTH='50%' ALIGN='LEFT'> </TD> </TR> <TR> <TD VALIGN="TOP"> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <B> Textarea width:<BR> Width in characters of the SQL editing area.<BR>EOF foreach $val ('30','40','50','60','70','80','100','125','150') { print "<INPUT TYPE=RADIO NAME='statement_id' VALUE='$val'"; if ($val == $textarea_w) { print " CHECKED>$val\n"; } else { print " >$val\n"; } }print <<"EOF"; <HR WIDTH='50%' ALIGN='LEFT'> </TD> </TR> <TR> <TD VALIGN="TOP"> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <B> Textarea height:<BR> Height in characters of the SQL editing area.<BR>EOF foreach $val ('5','10','15','20','25','30','35','40','45','50') { print "<INPUT TYPE=RADIO NAME='user' VALUE='$val'"; if ($val == $textarea_h) { print " CHECKED>$val\n"; } else { print " >$val\n"; } }print <<"EOF"; <HR WIDTH='50%' ALIGN='LEFT'> </TD> </TR> <TR> <TD VALIGN="TOP"> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <B> Row display default:<BR> Number of rows to return on a table/view row display.<BR>EOF foreach $val ('1','5','25','50','100','250','500','all') { print "<INPUT TYPE=RADIO NAME='whereclause' VALUE='$val'"; if ($val eq $rowdisplay) { print " CHECKED>$val\n"; } else { print " >$val\n"; } }print <<"EOF"; <HR WIDTH='50%' ALIGN='LEFT'> </TD> </TR> <TR WIDTH=50%> <TD ALIGN=CENTER> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <INPUT TYPE=HIDDEN NAME='database' VALUE='$database'> <INPUT TYPE=HIDDEN NAME='object_type' VALUE='SETPROPS'> <INPUT TYPE=SUBMIT NAME='foobar' VALUE='Submit changes'> </TD> </TR> </FORM> <TR></TABLE>EOF logit("Exit subroutine showProps");}sub showThemes { logit("Enter subroutine showThemes"); # Display all of the themes. my ($currenttheme,@themevars); $currenttheme = $theme; text("Select a color theme for your default.<BR>Your current theme is \"$currenttheme\"."); foreach $theme (sort keys %themes) { logit(" Displaying theme $theme"); @themevars = @{ $themes{$theme} }; $description = $themevars[0] or $description = "undefined"; $bgcolor = $themevars[1] or $bgcolor = "undefined"; $menuimage = $themevars[2] or $menuimage = "undefined"; $bgimage = $themevars[3] or $bgimage = "undefined"; $fontcolor = $themevars[4] or $fontcolor = "undefined"; $headingfontcolor = $themevars[5] or $fontcolor = "undefined"; $infocolor = $themevars[6] or $infocolor = "undefined"; $linkcolor = $themevars[7] or $linkcolor = "undefined"; $font = $themevars[8] or $font = "undefined"; $headingfont = $themevars[9] or $font = "undefined"; $fontsize = $themevars[10] or $fontsize = "undefined"; $headingcolor = $themevars[11] or $headingcolor = "undefined"; $cellcolor = $themevars[12] or $cellcolor = "undefined"; $bordercolor = $themevars[13] or $bordercolor = "undefined"; print <<"EOF";<TABLE BORDER=0 BGCOLOR='$bordercolor' CELLPADDING=1 CELLSPACING=0> <TR> <TD VALIGN="TOP" WIDTH=100%> <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 WIDTH=100%> <TR> <TD BGCOLOR='$bgcolor'> <TABLE CELLPADDING=20> <TH><A HREF=$scriptname?database=$database&object_type=SETTHEME&arg=$theme TARGET=_top>$theme</A></TH> <TR> <TD BGCOLOR=$bgcolor ALIGN=CENTER><FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <TABLE BORDER=0 BGCOLOR='$bordercolor' CELLPADDING=1 CELLSPACING=0> <TR> <TD VALIGN="TOP" WIDTH=100%> <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 WIDTH=100%> <TH BGCOLOR='$headingcolor'><FONT COLOR='$headingfontcolor' SIZE='$fontsize' FACE='$headingfont'>Table headings</TH> <TR ALIGN="CENTER"> <TD BGCOLOR='$cellcolor'><FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> Table cells </TD> </TR> </TABLE> </TD> </TR> </TABLE><FONT COLOR='$linkcolor' SIZE='$fontsize' FACE='$font'><BR>link color </TD> </TR> </TABLE> </TD> </TR> </TABLE> </TD> </TR></TABLE><P>EOF } logit("Exit subroutine showThemes");}sub validateIndex { logit("Enter subroutine validateIndex"); my ($sql,$text,$link); $sql = "VALIDATE INDEX $schema.$object_name"; runSQL($sql); $sql = "$copyrightSELECT REPEAT_COUNT \"Repeat count\", KEYS_WITH_REPEAT_COUNT \"Keys with repeat count\"FROM INDEX_HISTOGRAM"; $text = "This table shows the number of times that one or more index keys is repeated in the table, and the number of index keys that are repeated that many times."; $link = ""; DisplayTable($sql,$text,$link); $sql = "$copyrightSELECT HEIGHT \"Height\", TO_CHAR(BLOCKS,'999,999,999,999') \"Blocks\", TO_CHAR(LF_ROWS,'999,999,999,999') \"Leaf rows\", TO_CHAR(LF_BLKS,'999,999,999,999') \"Leaf blocks\", TO_CHAR(LF_ROWS_LEN,'999,999,999,999') \"Leaf row sum\", TO_CHAR(LF_BLK_LEN,'999,999,999,999') \"Leaf block usable space\", TO_CHAR(BR_ROWS,'999,999,999,999') \"Branch rows #\", TO_CHAR(BR_BLKS,'999,999,999,999') \"Branch blocks #\", TO_CHAR(BR_ROWS_LEN,'999,999,999,999') \"Blocks length sum\", TO_CHAR(BR_BLK_LEN,'999,999,999,999') \"Branch block usable space\", TO_CHAR(DEL_LF_ROWS,'999,999,999,999') \"Deleted leaf rows #\", TO_CHAR(DEL_LF_ROWS_LEN,'999,999,999,999') \"Deleted rows length\", TO_CHAR(DISTINCT_KEYS,'999,999,999,999') \"Distinct keys #\", TO_CHAR(MOST_REPEATED_KEY,'999,999,999,999') \"Most repeated key #\", TO_CHAR(BTREE_SPACE,'999,999,999,999') \"Total space allocated\", TO_CHAR(USED_SPACE,'999,999,999,999') \"Total space used\", TO_CHAR(PCT_USED,'999')||'%' \"Percent used\", TO_CHAR(ROWS_PER_KEY,'999,999,999,999') \"Rows per distinct key\", TO_CHAR(BLKS_GETS_PER_ACCESS,'999,999,999,999') \"Block gets per access\"FROM INDEX_STATS"; $text = "Index statistics."; $link = ""; DisplayTable($sql,$text,$link); logit("Exit subroutine validateIndex");}sub showIndex { logit("Enter subroutine showIndex"); my ($sql,$text,$link,$foo,$partitioned); # Index structure $sql = "$copyright SELECT TABLE_NAME \"Table name\", TABLE_OWNER \"Owner\", COLUMN_NAME \"Column name\", COLUMN_LENGTH \"Column length\" FROM DBA_IND_COLUMNS WHERE INDEX_NAME = '$object_name' AND INDEX_OWNER = '$schema' ORDER BY COLUMN_POSITION"; $object_type = lc $object_type; $text = "Structure of $object_type $object_name"; $link = ""; DisplayTable($sql,$text,$link);# General $sql = "$copyrightSELECT A.TABLESPACE_NAME \"Tablespace name\", TO_CHAR(B.CREATED,'Month DD, YYYY - HH24:MI') \"Date created\", TO_CHAR(B.LAST_DDL_TIME,'Month DD, YYYY - HH24:MI') \"Last DDL time\", TO_CHAR(A.EXTENTS,'999,999,999,999') \"Extents\", TO_CHAR(A.INITIAL_EXTENT,'999,999,999,999') \"Initial extent\", TO_CHAR(A.NEXT_EXTENT,'999,999,999,999') \"Next extent\", TO_CHAR(A.MAX_EXTENTS,'999,999,999,999') \"Max extents\", TO_CHAR(A.BYTES,'999,999,999,999') \"Bytes\", B.STATUS \"Status\"FROM DBA_SEGMENTS A, DBA_OBJECTS B WHERE A.SEGMENT_NAME = '$object_name' AND A.SEGMENT_TYPE = 'INDEX' AND A.OWNER = '$schema' AND B.OBJECT_NAME = '$object_name' AND B.OBJECT_TYPE = 'INDEX' AND B.OWNER = '$schema'"; $object_type = lc $object_type; $text = "General info: $object_type $object_name"; $link = ""; DisplayTable($sql,$text,$link);# Check to see if index is partitioned, if Oracle8 if ($oracle8) { $sql = "$copyrightSELECT PARTITIONEDFROM DBA_INDEXES WHERE INDEX_NAME = '$object_name' AND OWNER = '$schema'"; $cursor=$dbh->prepare($sql); $cursor->execute; $foo = $cursor->fetchrow_array; $cursor->finish; if ($foo eq "YES") { $partitioned = "Yep"; } }# If partitioned, show some additional info. if ($partitioned) { $sql = "$copyrightSELECT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -