473,598 Members | 3,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Do I miss anything?

DB2 8.2

I try to add a column into a table. I think the procedure inside DB2
is:

1. Create a temporary table which has the old table stucture and data.
2. Drop the original table
3. Create the new table with the added column
4. Insert data back into the new table from that temporary table.

I have to say I am shocked by this procedure.

What about if the table has 100 mils rows? If so, it will take much
time to finish step 1 and 4. Also it requires extra storage.

Do I miss anything in DB2?

Thanks,

Nov 12 '05 #1
8 1395
I may be wrong, but I do not think this is done.

My system has very large tables with 30+ M rows and I often add columns
to it.

The procedure you mentioned only applies when you are dropping a
column. Also, you have to perform these steps manually.

-Michel

ib****@yahoo.co m escreveu:
DB2 8.2

I try to add a column into a table. I think the procedure inside DB2
is:

1. Create a temporary table which has the old table stucture and data.
2. Drop the original table
3. Create the new table with the added column
4. Insert data back into the new table from that temporary table.

I have to say I am shocked by this procedure.

What about if the table has 100 mils rows? If so, it will take much
time to finish step 1 and 4. Also it requires extra storage.

Do I miss anything in DB2?

Thanks,


Nov 12 '05 #2
ib****@yahoo.co m wrote:
DB2 8.2

I try to add a column into a table. I think the procedure inside DB2
is:

1. Create a temporary table which has the old table stucture and data.
2. Drop the original table
3. Create the new table with the added column
4. Insert data back into the new table from that temporary table.

I have to say I am shocked by this procedure.

What about if the table has 100 mils rows? If so, it will take much
time to finish step 1 and 4. Also it requires extra storage.

Do I miss anything in DB2?

Which version/platform of DB2 are you using?
In DB2 for LUW check out the ALTER TABLE .. ADD COLUMN statement
It is INSTANTANEOUS and under transaction control. There isn't even
storage needed to extend the existing rows with the new column.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3
"I may be wrong, but I do not think this is done.

My system has very large tables with 30+ M rows and I often add columns
to it.

The procedure you mentioned only applies when you are dropping a
column. Also, you have to perform these steps manually. "

I performed the 'adding column' procedure from control center. In the
end of it, I got the pop windows which showed all the steps in my post.
Also I did see there's a temp table which has the same structure and
data during the process.

The version is the latest one: 8.2
You can give a try also.

Nov 12 '05 #4
"Which version/platform of DB2 are you using?"

8.2 on AIX

Nov 12 '05 #5
ib****@yahoo.co m wrote:
"Which version/platform of DB2 are you using?"

8.2 on AIX

CREATE TABLE T(C1 INT);
INSERT INTO T VALUES (1), (2), (3);
ALTER TABLE T ADD COLUMN C2 INTEGER WITH DEFAULT -1;
ALTER TABLE T ALTER COLUMN C2 DROP DEFAULT;
INSERT INTO T VALUES (10, 11), (12, 13);
SELECT * FROM T;

C1 C2
----------- -----------
1 -1
2 -1
3 -1
10 11
12 13

5 record(s) selected.

What am I missing?

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #6
Serge Rielau wrote:
ib****@yahoo.co m wrote:
"Which version/platform of DB2 are you using?"

8.2 on AIX

CREATE TABLE T(C1 INT);
INSERT INTO T VALUES (1), (2), (3);
ALTER TABLE T ADD COLUMN C2 INTEGER WITH DEFAULT -1;
ALTER TABLE T ALTER COLUMN C2 DROP DEFAULT;
INSERT INTO T VALUES (10, 11), (12, 13);
SELECT * FROM T;

C1 C2
----------- -----------
1 -1
2 -1
3 -1
10 11
12 13

5 record(s) selected.

What am I missing?

Cheers
Serge

99,999,995 rows :)

--
Anton Versteeg
IBM Netherlands
Nov 12 '05 #7
Control Center:
<left window>=>All Cataloged
Systems=><serve r>=>Instances=> <instance>=>Dat abases=><databa se>=>Tables=><t able>

<right window>=><table >=><right click>=>Alter=> Add=>Column Name typed
in A=>OK=>Show SQL:

CONNECT TO <database>;
ALTER TABLE <schema>.<table > ADD COLUMN A CHARACTER (10) ;
CONNECT RESET;

Is that what you tried?

Nov 12 '05 #8
Anton Versteeg wrote:
Serge Rielau wrote:
ib****@yahoo.co m wrote:
"Which version/platform of DB2 are you using?"

8.2 on AIX

CREATE TABLE T(C1 INT);
INSERT INTO T VALUES (1), (2), (3);
ALTER TABLE T ADD COLUMN C2 INTEGER WITH DEFAULT -1;
ALTER TABLE T ALTER COLUMN C2 DROP DEFAULT;
INSERT INTO T VALUES (10, 11), (12, 13);
SELECT * FROM T;

C1 C2
----------- -----------
1 -1
2 -1
3 -1
10 11
12 13

5 record(s) selected.

What am I missing?

Cheers
Serge

99,999,995 rows :)

I _guarantee_ that it will be as fast!

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #9

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

Similar topics

7
1902
by: glutinous | last post by:
I've looked at manuals and experimented until my brain's oozing out of my ears, and I still can't figure out what I anticipate will prove to be fairly basic css layout knowledge. I'd be amazed if this was the first (or even if only the 100th) time someone has asked about this sort of situation. So I apologise, not least for the awkwardness of my attempt below to illustrate my ignorance. I could produce a table such as this...
18
1403
by: Parahat Melayev | last post by:
#include <stdio.h> #include <stdlib.h> #include <limits.h> int main() { unsigned char *c; c = malloc(sizeof(unsigned char)); printf("size of unsigned char: %d\n", sizeof(unsigned char)); printf("size of c: %d\n", sizeof(c));
4
1190
by: Gav | last post by:
I have a select statement with parameter ie SELECT * FROM USERS WHERE UserID = @UserID If I do not supply @UserID I get an error, how can I set it up so that if I don't supply @UserID it returns all of them? Help would be much appreciated
1
1526
by: kmounkhaty | last post by:
Hi Guru, My profiler trace does not display SP:CACHEMISS event, even thought I drop store proc, clear both data cache and buffer cache but still does not work. Every thing works fine like: cachehit, cacheinsert,cacheremove,executecontexthit etc... Is there any special option that I need to turn it on?
32
2576
by: cj | last post by:
When I'm inside a do while loop sometimes it's necessary to jump out of the loop using exit do. I'm also used to being able to jump back and begin the loop again. Not sure which language my memories are of but I think I just said loop somewhere inside the loop and it immediately jumped back to the start of the loop and began again. I can't seem to do that in .net. I this functionality available?
53
2828
by: Paul Watt | last post by:
Hi again, Ok so I've got two new problems with this layout http://www.paulwatt.info/test/turn/ 1) When I increase the width of the Maincontent Div from 73% to 74% to line it up with the right hand side of the page, the whole div drops to below the level of the leftcell div. put it back to 73% and it goes back to its correct posistion. 2) It looks fine in IE but a absolute dogs dinner in FF. whys this?
28
1712
by: Useful Info | last post by:
Like on 9/11, the Federal Government apparently WANTED people to die at the hands of Cho at VA Tech, because they told campus police not to pursue Cho after the double homicide occurred. Story via http://Muvy.org
8
12895
by: anukedari | last post by:
Hi, Could any boby please help to get the answers for the following questions: Is Apache always sends "X-Cache:MISS" header even when caching is off (disable)? or Can we say that cache settings are enable if it sends "X-Cache:MISS" header in the response? Your help would be appreciated.
0
1389
by: manikandan | last post by:
dont miss it just open dont miss it just open dont miss it just open #############################
0
7902
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,...
1
8050
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
8265
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
6719
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
5850
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
5438
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
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2412
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
1
1504
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.