473,776 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

select * view and alter table

I have a view defined as select * on base table. When base table is
altered to add new column, new column does not appear when selected
from view. Here is what I did to test.

db2 "create table test_sch.test ( c1 smallint, c2 smallint)"
db2 "insert into test_sch.test values(1,1)"
db2 "insert into test_sch.test values(2,2)"

db2 "create view test_sch.test_v as select * from test_sch.test"

db2 "select * from test_sch.test_v "

C1 C2
------ ------
1 1
2 2

2 record(s) selected.
db2 "alter table test_sch.test add c3 smallint "

db2 "select * from test_sch.test"

C1 C2 C3
------ ------ ------
1 1 -
2 2 -

2 record(s) selected.

db2 "select * from test_sch.test_v "

C1 C2
------ ------
1 1
2 2

2 record(s) selected.

As the view is defined as select * from test_sch.test,
I was expecting select * from test_sch.test_v view to return C3 also,
but it didn't. Any idea why?

I had to drop the view and recreate it to see c3. I am curious to know
why it did not take c3 when select * is used in view definition.

Thanks for your time.
Manoj
Mar 11 '08 #1
4 6311
Dave Hughes wrote:
Anyway, I suspect this is one of the reasons that "SELECT *" is
considered by some to be a horrible mistake :-)
Not only "considered " - it is a horrible mistake. ;-)

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Mar 12 '08 #2
A bit off topic, but has anyone thought to add a function key to an
SQL editor that will expand a "SELECT *" or "INSERT INTO" with the
full column list?
Mar 12 '08 #3
--CELKO-- wrote:
A bit off topic, but has anyone thought to add a function key to an
SQL editor that will expand a "SELECT *" or "INSERT INTO" with the
full column list?
Data Studio has a lot of inteliSense technology. More importantly it
does such things in pureQuery (LINQ in Java)
Whether it has an "all columns" options I don't know.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Mar 12 '08 #4
aka

"Serge Rielau" <sr*****@ca.ibm .comwrote in message
news:63******** *****@mid.indiv idual.net...
--CELKO-- wrote:
>A bit off topic, but has anyone thought to add a function key to an
SQL editor that will expand a "SELECT *" or "INSERT INTO" with the
full column list?
Toad for DB2 can do, even in the freeware edition
Data Studio has a lot of inteliSense technology. More importantly it does
such things in pureQuery (LINQ in Java)
Whether it has an "all columns" options I don't know.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Mar 13 '08 #5

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

Similar topics

3
3807
by: Thomas R. Hummel | last post by:
I am using SQL Server 2000, SP3. I created an updatable partitioned view awhile ago and it has been running smoothly for some time. The partition is on a DATETIME column and it is partitioned by month. Each month a stored procedure is scheduled that creates the new month's table, and alters the view to include it. Again... working like a charm for quite some time. This past weekend I moved some of the first tables onto a new file...
9
3404
by: mfyahya | last post by:
Hi, I'm new to databases :) I need help speeding up select queries on my data which are currently taking 4-5 seconds. I set up a single large table of coordinates data with an index on the fields I use most frequently in select queries. The data is about 100MB and index is 80MB. The table has the following structure: CREATE TABLE `ptimes` ( `id` INT UNSIGNED NOT NULL , `rc` CHAR ( 1 ) UNSIGNED NOT NULL ,
10
5637
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I create a single View and specify also in this View the WHERE clause that is common in these stored procedures, I will have the new stored procecures changed to be like:
8
2328
by: btober | last post by:
I'm finding that column defaults are not being assigned to nulls when I do an insert by way of a an ON INSERT rule on a view. For example, the following script \set ON_ERROR_STOP ON \c template1 --DROP DATABASE testdb; CREATE DATABASE testdb; \c testdb
14
10924
by: Demetris | last post by:
Hello people! I have a table with more than 30 million rows,a lot of columns and indexes. We need to change a column which is dec(15,2) and nullable to have a default value of zero. As I know you cannot alter a column unless it is varchar. I was thinking to export the whole table in ixf format, create the new table with the new definition and then import with insert into. Or rename the original table, create a new one and insert into new...
33
6665
by: Peter | last post by:
People are telling me it is bad to put select * from <atable> in a view. I better should list all fields of the table inside the definition of the view. I dont know exactly why but some say: A select * from makes sql server does a table scan.
3
1716
by: Wes Groleau | last post by:
Never say never..... One of my applications loads a huge amount of data from a text file, sifts through and discards much of it, and rearranges what's left. Finally, it is added to similar data from many other files. For that last step, SELECT * is the sensible way to go. If you really do want everything, why force yourself to have to edit the select if ever a column is added or deleted?
0
2076
by: bimeldip | last post by:
Hi, I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be able to change field name or data type of field But the problem that i'm facing currently is that i am unable to display the list of fields on the html page. i'm guessing its because i'm using "show fields from " unlike the other page where i...
5
2414
JustJim
by: JustJim | last post by:
I think I've just bumped into the limits of the Having Clause (Help file says 40 expressions, Mary says 99 and I know who I trust). The question is, what happens if you overload the select... into... having clause? Does the whole thing fail? Is the clause truncated somehow? It appears that the target table is being deleted, but then not re-created! Here's what I got so far. Please pardon the long lines, I don't type 'em, I just paste...
0
9464
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
10122
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
10061
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
8954
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
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5368
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.