How can you split a table in to exactly half?

Answer Posted / reddy kanupuru

Hi,

Here i am giving the procedure , how to make the table into
half..... using program... I dont know whether any direct
SQL command is there or not. This is just for ur idea what
i know.

1) Find the total number of rows in a table using count(*)

2) Declare two variable in working storage section.
eg: 02 A pic 9(4) .
02 B pic 9(2).

store the count no into one variable .assume u stored that
in A.

then divide that by 2. so u will get half of the rows in a
table. strore that value in B.

3) Take another variable name C .

eg: 02 c pic 9(4) value 0.

perform para1 until B =C

para1:

Retrive the row from the table.

move to corresponding host variables ( use table to store
muliple rows ).

insert into table(u can insert multiple rows at a time ...)

do the same for storing the other half into the another
table.

means here 1 st half rows were stored in one temp
table .... the other in the one table.

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are bind concepts in db2 cobol?

645


Define db2 and its databases?

616


What is explain plan in db2?

586


What is view db2?

621


What is dbrm?

636






How to check last update on table in db2?

624


What is ibm db2 database?

530


what is the sqlcode -501

11278


Why do chiropractors use drop table?

656


What is the use of dclgen in db2?

586


Explain about rct in db2?

633


What does a deadlock mean in DB2?

647


If I have a view which is a join of two or more tables, can this view be updateable?

688


What is a db2 schema?

760


How to find primary key of a table in db2?

607