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
How do I connect my db2 database to ibm?
What is a trigger in the db2 database?
What do you mean by commit and rollback?
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.
How do I add a column to an existing table in db2?
Explain the contents that are a part of dclgen.
What type of database is db2?
what is the role of the cursor in db2?
What are bind parameters in db2?
What are the prerogatives?
What is a db2 collection?
What is runstats utility in db2?
What is dbrm in db2 database?
How to find schema of a table in db2?
What is null value in db2?