Delete N rows from the DB2 chart

Source: Internet
Author: User

First,You need to update your"Relational"Knowledge about database management systems.No"Top"Or"Bottom"OfNConcept of rows.However, the result set has the concept of "TOP" or "bottom "..You can useFETCH FIRST N ROWS ONLYClause to get the startNRows,But getNRows are more difficult.To achieve this,You need to use a scroll pointer.The scroll pointer allows you to read/All rows are moved before and after the result set. I suggest you readDB2 SQLReference manual andDB2The content of the scroll pointer in the application manualDB2The manual can be downloaded free of charge from the Internet ). Basically, you should use a scroll pointer.FETCH LASTStatement, and then useFETCH PRIORStatement LoopN-1Times. That will give any result set"Bottom"
OfNRows or unclassified rows ).

I don't understand why you want to delete your other questions from the chart.NRows. What is the data in these rows important? I guess you are asking howDELETEOfWHEREThe answer is no. You mustWHERESpecify the conditionsFOR UPDATETo open a pointer, and then you needNThe next line opensFETCHAndDELETE WHERE CURRENTPointer. Of course, this means you have to rewrite a program.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.