473,847 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ivendor name ON reports.transby vendor05
(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 35333
"Shirley" <sm****@mail.go v.gu> wrote in message
news:11******** **************@ q12g2000cwa.goo glegroups.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.Ivendor name ON reports.transby vendor05
(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
18001
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
7372
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 functions a create index script of all indexes. (The result will be 4 scripts) Arno de Jong, The Netherlands.
1
2384
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 records by the purchase price so I thought I'd create an index to help out my selects: CREATE INDEX purchasepriceidx ON mytable (purchaseprice);
2
1723
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 tradein_clients=# Regds mallah.
4
5885
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
8508
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 configured 24 checkpoint segments, which I expect gives me a worst-case usage in pg_xlog of 384MB. Unfortunately, during the CREATE INDEX, pg_xlog becomes full!
3
2640
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 way to ignore those rows with nulls in index creation?
0
1277
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 " & TableName & " IN '" & NewDBName & "' FROM " & TableName & " WHERE 1=2;" DoCmd.RunSQL sqlString 'The WHERE 1=2 ensures that no records are copied - only the
4
3273
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 Table Queries and Indexing via SQL. For example ...
2
7260
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 is the solution for it? Thanks,
0
9892
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9735
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10996
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10658
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10718
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10347
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9497
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4541
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4133
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.