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
How does db2 sample database connect?
What is db2 connect?
How do I import a csv file into db2?
What is the use of predicate?
What is access path in db2?
What are foreign keys in db2?
What is sqlca?
What is ibm db2 connect?
What is the difference between using bind () and rebind () methods of naming class?
have 3 tables table1, table2 and table3 which contains employee information. table1 is master table, table2 contains emp details like emp no and so on, table 3 contains emp salary. so if any emp leave company between 25th - 30th of every month it has to get updated in tables. but it is not getting updated. What is the reason.
What is data manager?
What are the contents of a dclmgen?
can all users have the privilage to use the sql statement select * (dml)?
What is the physical storage length of timestamp data type?
How to check last update on table in db2?