In my table having 100 Rec. How can I delete the 7th row??
(we don't know what is data inside the table)
Answers were Sorted based on User's Feedback
Answer / harsha
Use DELETE FROM TabName
The above command will delete all rows of the table with
out deleting the table.
Now if we want to delete 7th row and we don't know the
actual data in that row, then in that case we need to
create a new temporary result table, that contains only one
desired record which you want to delete.
Here are the steps.
1 Select only 7 row data.
2 Sort it in descending order(ORDER BY calue)
3 Select only first row
4 Now you have a result table with only 1 and desired record
Is This Answer Correct ? | 4 Yes | 1 No |
Answer / mdv
DELETE FROM TABLE_NAME
WHERE RID(TABLE_NAME) = 7 ;
Works DB2 (V9 Onwards)
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / giri reddy
use cursor to find out the primary key column value in that
row, then delete tha row using the primary key
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / rajeev
In this scenario RRN will be useful.
DELETE FROM <FILENAME> F1 WHERE RRN(F1) = 7
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / tim v
Are we talking the 7th row as sorted by key or 7th physical row? Since the rows aren't normally physically stored in order, I'd have to go with the latter.
Everyone seems to assume there is a PK on the table, but yet we don't know anything about the data... Again, this points to 7th physical row.
I'd go with the delete where RID(table) = 7 option since this assumes the 7th row inserted based on position and not value.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / m sharib
delete from table1 where policy_no =(select policy_no from table1 limit 6,1);
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ajay
we need to know atleast 1 column data, else we can not delete data from table.
Is This Answer Correct ? | 2 Yes | 4 No |
Answer / sherman_li
Actually, you don't need to delete this data, just move
foward the remaining data(from 8th to 100th), for example,
8th -> 7th
9th -> 8th
...
100th -> 99th
hope this is what you want
Is This Answer Correct ? | 0 Yes | 11 No |
What is the use of with ur in db2?
What does the CHECK Utility do ?
What is commit in db2?
How does DB2 use multiple table indexes?
Assuming that a site's standard is that pgm name = plan name, what is the easiest way to find out which Will precompile of an DB2-COBOL program bomb, if DB2 is down?
What is RUNSTATS?
SET is the ANSI standard for variable assignment, SELECT is not. SET can only assign one variable at a time, SELECT can make multiple assignments at once. If assigning from a query, SET can only assign a scalar value. If the query returns multiple values/rows then SET will raise an error. SELECT will assign one of the values to the variable and hide the fact that multiple values were returned (so you'd likely never know why something was going wrong elsewhere - have fun troubleshooting that one) When assigning from a query if there is no value returned then SET will assign NULL, where SELECT will not make the assignment at all (so the variable will not be changed from it's previous value) As far as speed differences - there are no direct differences between SET and SELECT. However SELECT's ability to make multiple assignments in one shot does give it a slight speed advantage over SET.
Can there be more than one cursor open for any program?
When do you specify the isolation level?
What techniques are used to retrieve data from more than one table in a single SQL statement?
What are types of indexes?
db2 maintains information about the data... a.in tables. b.in a set of tables known as db2 catalog. c.in db2 database. d.none of the above.