473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Can I create an index on a view?

We are running DB2 on iSeries V5R2.
Using AQUA DATA STUDIO with a connection to our iSeries, I created a
view using SQL and I am trying to create an index on this view using
the code below.

CREATE INDEX reports.Ivendorname ON reports.transbyvendor05
(vendorname)
However I get the following error:
Error: [SQL0156] TRANSBYVENDOR05 in REPORTS not a table.
Is it possible to create an index on a view? If not, what other options

do I have to improve
the performance of my queries on the view I created?
Thanks, Shirley..

May 11 '06 #1
2 35018
"Shirley" <sm****@mail.gov.gu> wrote in message
news:11**********************@q12g2000cwa.googlegr oups.com...
We are running DB2 on iSeries V5R2.
Using AQUA DATA STUDIO with a connection to our iSeries, I created a
view using SQL and I am trying to create an index on this view using
the code below.

CREATE INDEX reports.Ivendorname ON reports.transbyvendor05
(vendorname)
However I get the following error:
Error: [SQL0156] TRANSBYVENDOR05 in REPORTS not a table.
Is it possible to create an index on a view? If not, what other options

do I have to improve
the performance of my queries on the view I created?
Thanks, Shirley..


No, you can only create an index on a table. When you access a table via a
view, DB2 will may the indexes on the table to process the view (if doing so
is the most efficient access path).

Views do not exit as data that has been materialized. They are just a filter
in front of one or more tables that makes accessing the data more convenient
(such as when the join predicates are in the view so the user/programmer
does not have to do it), or views can be used provide extra security by only
letting users see certain columns or certain rows. Views can also be used to
change column names in query tool that returns the data, and for other
similar reasons.

When you access DB2 via a view, DB2 takes the SQL you have written against
the view, and the SQL in the view, and creates a single SQL statement that
is sent to the optimizer and data-manager for processing.
May 11 '06 #2
"Mark A" <no****@nowhere.com> wrote in message
news:eo******************************@comcast.com. ..
No, you can only create an index on a table. When you access a table via a
view, DB2 will may the indexes on the table to process the view (if doing
so is the most efficient access path).

Views do not exit as data that has been materialized. They are just a
filter in front of one or more tables that makes accessing the data more
convenient (such as when the join predicates are in the view so the
user/programmer does not have to do it), or views can be used provide
extra security by only letting users see certain columns or certain rows.
Views can also be used to change column names in query tool that returns
the data, and for other similar reasons.

When you access DB2 via a view, DB2 takes the SQL you have written against
the view, and the SQL in the view, and creates a single SQL statement that
is sent to the optimizer and data-manager for processing.


Correction to 2nd sentence:

When you access a table via a view, DB2 may use the indexes on the table to
process the view (if doing so is the most efficient access path).
May 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: M. Mehta | last post by:
It seems that you can not create a materialized view if you are using outer joins...can someone please verify this? Thanks M. Mehta Please follow my example below: created 2 tables:
1
by: A.M. de Jong | last post by:
Can I dynamically (from a stored procedure) generate a create table script of all tables in a given database (with defaults etc) a create view script of all views a create function script of all...
1
by: Stephane Charette | last post by:
QUICK VERSION: How do I create an index on a field of type "MONEY"? ----------------------------- LONG VERSION: I have a table with a field of type "money". I very often need to access...
2
by: Rajesh Kumar Mallah | last post by:
Hmmm... am i doing anything really silly? tradein_clients=# CREATE INDEX profile_master2 on profile_master (lower( btrim(email) ) ); ERROR: parser: parse error at or near "(" at character 61...
4
by: maricel | last post by:
Could someone confirm which tablespace is being used when running ALTER & CREATE INDEX. Is it the tempspace or the tablespace where the table resides? Many thanks, maricel
17
by: Jeffrey W. Baker | last post by:
Greetings, I have a 23GB data table upon which I am building a primary key of three columns. The data is mounted in a 137GB device and pg_xlog is mounted on a separate 3.5GB device. I have...
3
by: Bob Stearns | last post by:
I am creating an index on a column which is 40% NULLS. The process seems to run forever, though a count of the number of values runs in milliseconds. This leads to the subject question: is there a...
0
by: Owen Jenkins | last post by:
Hi, My application allows users to create a new back end for separate purposes. It does this by using Make Table Queries and Indexing via SQL. For example ... sqlString = "SELECT * INTO " &...
4
by: Owen Jenkins | last post by:
Hi, No-one replied to this when I sent it last week. Any bites out there today?? ----- My application allows users to create a new back end for separate purposes. It does this by using Make...
2
rsrinivasan
by: rsrinivasan | last post by:
Hi all, I want to create index on view. Is it posiible? When i create index on view, it throws the error Cannot create index on view 'q_Invoices_Issued' because the view is not schema bound.. What...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.