473,467 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Commit during insert

I need to increase the length of CD column from char(5) to char(7) in
DB2 V8.2. I am doing it this way:

1. create new_table with CD char(7)
2. do 'insert into new_table select * from Original_table'
3. drop all constraints/dependent objects on the Original_table
4. rename Original_table to Original_table_Old
5. rename new_table to Original_table
6. create all constraints and dependent objects on the Original_table

It works. But, for the larger tables, step 2 has problem. I have a
table with more than 5 million rows and 'insert into new_table select *
from Original_table' causes 'transaction log full'. Is there a way to
commit after every 10000 inserts?
I can go for EXPORT the table and IMPORT with commit count, but I don't
want to do that now. I cannot go for stored procedure either.

Is there anything like "create table new_table like original_table with
data" in DB2?

Thanks,
A C

Oct 5 '06 #1
7 14508
I will try this...

Alter table new_table NOT LOGGED INITIALLY ;
'insert into new_table select * from Original_table';
Commit;

and see how it works..

an*************@gmail.com wrote:
I need to increase the length of CD column from char(5) to char(7) in
DB2 V8.2. I am doing it this way:

1. create new_table with CD char(7)
2. do 'insert into new_table select * from Original_table'
3. drop all constraints/dependent objects on the Original_table
4. rename Original_table to Original_table_Old
5. rename new_table to Original_table
6. create all constraints and dependent objects on the Original_table

It works. But, for the larger tables, step 2 has problem. I have a
table with more than 5 million rows and 'insert into new_table select *
from Original_table' causes 'transaction log full'. Is there a way to
commit after every 10000 inserts?
I can go for EXPORT the table and IMPORT with commit count, but I don't
want to do that now. I cannot go for stored procedure either.

Is there anything like "create table new_table like original_table with
data" in DB2?

Thanks,
A C
Oct 6 '06 #2
<an*************@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
>I will try this...

Alter table new_table NOT LOGGED INITIALLY ;
'insert into new_table select * from Original_table';
Commit;

and see how it works..
The above will work if you submit it with auto-commit off. One way to set
auto-commit off is to use +c parm:

db2 +c -tvf script-name
Oct 6 '06 #3
i am not sure abt this but y dont you try

create the new table
take away permissions from the original table
export the data in an external file
load the data in the new table
drop dependencies
rename tables to old and original
recreate dependencies

i believe the export/load may be faster than inserts

thx
EA

Oct 6 '06 #4
i am not sure abt this but y dont you try

create the new table
take away permissions from the original table
export the data in an external file
load the data in the new table
drop dependencies
rename tables to old and original
recreate dependencies
i believe the export/load may be faster than inserts
thx
EA

Oct 6 '06 #5
EpsilonAurigae wrote:
i am not sure abt this but y dont you try

create the new table
take away permissions from the original table
export the data in an external file
load the data in the new table
You can combine the above two steps into a single LOAD from a cursor.
drop dependencies
rename tables to old and original
recreate dependencies
--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Oct 6 '06 #6
I wonder if for the reload (step 2) you can use something like the
following:

declare loadcurs cursor for select * from OLD_TABLE
load from loadcurs of cursor insert into NEW_TABLE

Seems to work.

What would be really cool is if the CREATE TABLE LIKE option allowed you to
redefine, drop, or add one or more columns, but have all other columns like
the one in the original table.
Something like:
create table NEW_TABLE like OLD_TABLE with changed (COL_X CHAR(25) NOT NULL)
new (NEW_COL1 VARCHAR(255) NOT NULL, NEW_COL2 INTEGER) without (COL_Y,
COL_Z)

Any such thing exist?

Frank

---
Frank Swarbrick
Senior Developer/Analyst - Mainframe Applications
FirstBank Data Corporation - Lakewood, CO USA
>>an*************@gmail.com<an*************@gmail.co m10/05/06 5:44 PM
I need to increase the length of CD column from char(5) to char(7) in
DB2 V8.2. I am doing it this way:

1. create new_table with CD char(7)
2. do 'insert into new_table select * from Original_table'
3. drop all constraints/dependent objects on the Original_table
4. rename Original_table to Original_table_Old
5. rename new_table to Original_table
6. create all constraints and dependent objects on the Original_table

It works. But, for the larger tables, step 2 has problem. I have a
table with more than 5 million rows and 'insert into new_table select *
from Original_table' causes 'transaction log full'. Is there a way to
commit after every 10000 inserts?
I can go for EXPORT the table and IMPORT with commit count, but I don't
want to do that now. I cannot go for stored procedure either.

Is there anything like "create table new_table like original_table with
data" in DB2?

Thanks,
A C

Oct 6 '06 #7
Frank Swarbrick wrote:
I wonder if for the reload (step 2) you can use something like the
following:

declare loadcurs cursor for select * from OLD_TABLE
load from loadcurs of cursor insert into NEW_TABLE

Seems to work.

What would be really cool is if the CREATE TABLE LIKE option allowed you
to redefine, drop, or add one or more columns, but have all other columns
like the one in the original table.
Something like:
create table NEW_TABLE like OLD_TABLE with changed (COL_X CHAR(25) NOT
NULL) new (NEW_COL1 VARCHAR(255) NOT NULL, NEW_COL2 INTEGER) without
(COL_Y, COL_Z)

Any such thing exist?
You can create a table based on the structure/schema of a query:

CREATE TABLE ... AS ( full-select )

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Oct 6 '06 #8

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

Similar topics

11
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to...
3
by: Alberto | last post by:
I've a complex stored procedure, that makes a lot of insert, update, delete and so on. I would like to make some commits durint this sp, but of course they are not "real" commit because who call...
0
by: Fan Ruo Xin | last post by:
Nothing got wrong with DB2 COMMIT, db2 cfg, ... Even you did an "insert some_id+1 ..." immediately after you did "select max(some_id) from .... " in session1. This will not block the operations...
8
by: Martin Staael | last post by:
When doing a UPDATE on a very large table it can take quite a long time due to the commit/rollback option. Is there any way on the client side to disable the commit/rollback option so that UPDATE...
2
by: harborboy76 | last post by:
Hi, I had posted one topic earlier, but somehow the link has been broken and I cannot see the topic. So sorry if this is a duplicate topic for some. Here is the issue that I'm running into....
0
by: MelApiso | last post by:
Hi, I have two databases in the same instance, sourcedb and targetdb. In sourcedb I created one table (t1). In targetdb I created another table (t2). In sourcedb I created one nickname (N2) for...
4
by: MelApiso | last post by:
Hi, I have two databases in the same instance, sourcedb and targetdb. In sourcedb I created one table (t1). In targetdb I created another table (t2). In sourcedb I created one nickname (N2) for...
7
by: m.gelosa | last post by:
Dear all, I got a problem on db2 for aix running a high workload messaging system with more than 5,000,000 of deliveries per day. During high peak hours it happens frequently that the...
5
by: Roger | last post by:
backup log testdb with truncate_only DBCC SHRINKFILE (testdb_log, 100) WITH NO_INFOMSGS backup database testdb to disk = '\\DC01\Backups\DB01\testdb.bak' with init and does the shrinkfile...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...
0
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...
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,...
0
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...
0
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...

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.