2
/* BEGIN_COMMON_COPYRIGHT_HEADER
4
* TOra - An Oracle Toolkit for DBA's and developers
6
* Shared/mixed copyright is held throughout files in this product
8
* Portions Copyright (C) 2000-2001 Underscore AB
9
* Portions Copyright (C) 2003-2005 Quest Software, Inc.
10
* Portions Copyright (C) 2004-2009 Numerous Other Contributors
12
* This program is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU General Public License
14
* as published by the Free Software Foundation; only version 2 of
15
* the License is valid for this program.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
* As a special exception, you have permission to link this program
27
* with the Oracle Client libraries and distribute executables, as long
28
* as you follow the requirements of the GNU GPL in regard to all of the
29
* software in the executable aside from Oracle client libraries.
31
* Specifically you are not permitted to link this program with the
32
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
33
* And you are not permitted to distribute binaries compiled against
36
* You may link this product with any GPL'd Qt library.
38
* All trademarks belong to their respective owners.
40
* END_COMMON_COPYRIGHT_HEADER */
42
#include "tobrowserbasewidget.h"
43
#include "toresultextract.h"
44
#include "toresultitem.h"
45
#include "toresulttableview.h"
46
#include "tostorage.h"
49
#include "tobrowserindexwidget.h"
52
static toSQL SQLIndexColsMySQL("toBrowser:IndexCols",
53
"SHOW INDEX FROM `:f1<noquote>`.`:f2<noquote>`",
54
"Display columns on which an index is built",
57
static toSQL SQLIndexCols("toBrowser:IndexCols",
58
"SELECT a.Table_Name,a.Column_Name,a.Column_Length,a.Descend,b.Column_Expression \" \"\n"
59
" FROM sys.All_Ind_Columns a,sys.All_Ind_Expressions b\n"
60
" WHERE a.Index_Owner = :f1<char[101]> AND a.Index_Name = :f2<char[101]>\n"
61
" AND a.Index_Owner = b.Index_Owner(+) AND a.Index_Name = b.Index_Name(+)\n"
62
" AND a.column_Position = b.Column_Position(+)\n"
63
" ORDER BY a.Column_Position",
66
static toSQL SQLIndexCols8("toBrowser:IndexCols",
67
"SELECT Table_Name,Column_Name,Column_Length,Descend\n"
68
" FROM SYS.ALL_IND_COLUMNS\n"
69
" WHERE Index_Owner = :f1<char[101]> AND Index_Name = :f2<char[101]>\n"
70
" ORDER BY Column_Position",
73
static toSQL SQLIndexCols7("toBrowser:IndexCols",
74
"SELECT Table_Name,Column_Name,Column_Length\n"
75
" FROM SYS.ALL_IND_COLUMNS\n"
76
" WHERE Index_Owner = :f1<char[101]> AND Index_Name = :f2<char[101]>\n"
77
" ORDER BY Column_Position",
80
static toSQL SQLIndexColsPgSQL("toBrowser:IndexCols",
82
" format_type(a.atttypid, a.atttypmod) as FORMAT,\n"
85
" FROM pg_class c LEFT OUTER JOIN pg_namespace n ON c.relnamespace=n.oid,\n"
87
" WHERE (n.nspname = :f1 OR n.oid IS NULL)\n"
88
" AND a.attrelid = c.oid AND c.relname = :f2\n"
90
" ORDER BY a.attnum\n",
94
static toSQL SQLIndexColsSapDb("toBrowser:IndexCols",
95
"SELECT tablename,columnname,len \"Length\",DataType,Sort \n"
96
" FROM indexcolumns \n"
97
" WHERE owner = upper(:f1<char[101]>) and indexname = upper(:f2<char[101]>)\n"
98
" ORDER BY indexname,columnno",
103
static toSQL SQLIndexInfoSapDb("toBrowser:IndexInformation",
104
"SELECT INDEXNAME,TABLENAME, TYPE, CREATEDATE,CREATETIME,INDEX_USED, DISABLED \n"
106
" WHERE owner = upper(:f1<char[101]>) and indexname = :f2<char[101]>\n",
107
"Display information about an index",
110
static toSQL SQLIndexInfo("toBrowser:IndexInformation",
111
"SELECT * FROM SYS.ALL_INDEXES\n"
112
" WHERE Owner = :f1<char[101]> AND Index_Name = :f2<char[101]>",
114
static toSQL SQLIndexStatistic("toBrowser:IndexStatstics",
115
"SELECT description \"Description\", value(char_value,numeric_value) \"Value\" \n"
116
" FROM indexstatistics \n"
117
" WHERE owner = upper(:f1<char[101]>) and indexname = :f2<char[101]>",
124
toBrowserIndexWidget::toBrowserIndexWidget(QWidget * parent)
125
: toBrowserBaseWidget(parent)
127
setObjectName("toBrowserIndexWidget");
129
columnView = new toResultTableView(this);
130
columnView->setObjectName("columnView");
131
columnView->setSQL(SQLIndexCols);
132
columnView->setReadAll(true);
134
resultInfo = new toResultItem(this);
135
resultInfo->setObjectName("resultInfo");
136
resultInfo->setSQL(SQLIndexInfo);
138
extentsView = new toResultExtent(this);
139
extentsView->setObjectName("extentsView");
141
extractView = new toResultExtract(this);
142
extractView->setObjectName("extractView");
144
statisticView = new toResultTableView(this);
145
statisticView->setObjectName("statisticView");
146
statisticView->setSQL(SQLIndexStatistic);
147
statisticView->setReadAll(true);
152
void toBrowserIndexWidget::changeConnection()
154
toBrowserBaseWidget::changeConnection();
156
toConnection & c = toCurrentConnection(this);
158
addTab(columnView, "&Columns");
160
if (toIsOracle(c) || toIsSapDB(c))
161
addTab(resultInfo, "Informations");
166
addTab(extentsView, "Extents");
171
addTab(statisticView, tr("&Statistic"));
173
statisticView->hide();
176
addTab(extractView, "Script");