How can you split a table in to exactly half?

Answer Posted / arpita

We can achieve this by using STRSQL and CPYF commands as
follows -

Type STRSQL, Press Shift + F1, option1 Change session
attributes.Type 3 for SELECT option, specify the output
file name and library (must be created in QTEMP, for a
temporary file). Press ENTER twice.

Then, type the following query -
select * from SAHAA/EMPDATA1
where rrn(EMPDATA1) in(
SELECT distinct dec((rrn(EMPDATA1)/2)) FROM SAHAA/EMPDATA1
) --> use your file and library name

Press Enter, the message File TEMP in QTEMP was created.
Restore the previous session attributes as follows -

Press Shift + F1, option1 Change session attributes.Type 1
for SELECT option. Press ENTER thrice.

Now, we would have half no. of records of EMPDATA1 in file
TEMP (say)

Now, simply use the CPYF command to copy TEMP file data
into EMPDATA1 as follows -

CPYF FROMFILE(QTEMP/TEMP) TOFILE(SAHAA/EMPDATA1) MBROPT
(*REPLACE)

Note:- TEMP is the file temporarily created in QTEMP, so
that it is no longer present in the system when the session
expires.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by between and in? Is between inclusive of specified range values?

672


What is copy pending status in db2?

640


I HAVE 500 ROW TO UPDATE I WOULD LIKE TO USE ROLLBACK ALONG WITH COMMIT.WHAT IS THE SYNTAX TO CODE COMMIT AND ROLLBACK FOR EVERY 100 ROWS.AND HOW THE CURSOR ROLLBACK TO THE LAST COMMITTING POINT.

2759


What is db2 plan table?

623


What is explain plan in db2?

592






Which command is used to connect to a database in DB2 ? Give the Syntax.

602


What does runstats do in db2?

607


How can you validate Sql errors during cursor operation in db2 pgms and where do you code?

1713


What is reorg and runstats in db2?

698


What is blu acceleration in db2?

608


What are the full forms of spufi and dclgen and why are they used?

662


How to retrieve rows from a db2 table in embedded sql?

732


What is ibm db2 used for?

604


What is the clustering index in the db2 database?

588


What action db2 takes when a program aborts in the middle of a transaction?

659