Delete all rows except 10 random rows

Hi,
how can I delete all rows from table JOBS except 10 random rows?
Someone asked it before (not here..): http://stackoverflow.com/questions/10820105/t-sql-delete-except-top-1
but I didn't understand the answer, and I don't think it will work in PL/SQL.
If the answer in StackOverflow does works in PL/SQL, I will glad if someone explains me with better example,
If the answer in StackOverflow does'nt work in PL/SQL, I will glad if someone gives me an example.
thanks!

Actually I found a problem in this solution.
delete from jobs where rowid not in (select rowid from jobs where rownum<=10) ;I used the above code to delete all rows except 10 in JOB_HISTORY table, but for some reason the rows that were chosen were only in the range in which (144<=EMPLOYEE_ID<=146).
I tried this several times and always i stayed with rows in this range.
Here are the queries:
SQL> select employee_id from job_history;
EMPLOYEE_ID
144
144
144
144
144
145
145
146
146
146
146
146
146
146
147
147
147
147
149
149
149
156
156
156
156
156
156
156
158
158
158
158
158
158
158
158
159
159
159
165
165
165
171
171
171
171
46 rows selected
SQL> delete from job_history where rowid not in (select rowid from job_history where rownum <= 15);
31 rows deleted
SQL> select employee_id from job_history;
EMPLOYEE_ID
144
144
144
144
144
145
145
146
146
146
146
146
146
146
147
15 rows selected
SQL>
Glad if someone can explain me why I get this result.
Thanks
Edited by: 998093 on 05:01 05/04/2013

Similar Messages

  • Is there any way to delete all cookies except those used on the home page?

    Is there any setting in Firefox which would permit me the deletion of all cookies on exit EXCEPT those associated with with specific pages? For example, the iGoogle home page requires a cookie to be set which recognizes the session created in a prior access. If all cookies are deleted on closure of Firefox, the user is required to sign in to iGoogle every time to see their home page. Currently you can delete cookies on exit or accept cookies based on exception. I would like to delete all cookies except those from permitted sources. There is no setting for this that I can find.

    You can let all cookies expire if you close Firefox and set an allow exception for domains that you want to keep the cookies from. Don't use [[Clear Recent History]] to clear cookies as that will remove all cookies including ones with an exception, but just let the others expire.
    You can always remove cookies manually, e.g. via a click on the favicon and More Information and View Cookies.
    You can see all permissions of the current domain here: Tools > Page Info > Permissions

  • HT1923 In trying to delete the Apple file in the Program/Common File I can delete all contents except the Internet Services folder.  Thus preventing me from deleting the Apple FIle.  Error message says I need permission to delete this file.  How do I proc

    Trying to delete the Apple Folder from Program Files/Common Files.  I can delete all the contents except for the Internet Services folder which prevents me from making the deletion.  The error message says "you need permission to delete this file".
    Discovered this problem when trying to upgrade from my 3G iPhone to a new 5S iPhone unsucessfully.

    See note 3 of Troubleshooting issues with iTunes for Windows updates.
    tt2

  • How can i delete all history, except open windows and tabs?

    hi, i can not find any way to delete all my firefox history, except open windows and tabs.
    i could not find any solution about in the web. i did try almost all settings in privacy settings, nothing works. any ideas how to do that, or maybe suggestions for add ons?

    Hello,
    Have you looked in:
    * History (or [[Image: New Fx Menu]] > History) > Clear Recent History...
    You can choose what you want cleared and the time frame.

  • Delete all pages except currently viewed?? Acrobat Javascript

    Hello All,
    I need to delete all pages in a PDF except the one that is currently being viewed. I thought I had it with this:
    var keepPage=this.pageNum
    this.deletePages({nStart: keepPage+1, nEnd: this.numPages -1});
    var keepPage=this.pageNum
    this.deletePages({nEnd: keepPage -1});
    But this only works if you are on a page other than the last page.
    I appreciate any help.

    Thank you so much. I had done this:
    var keepPage=this.pageNum
    if
    (this.numPages -1 > keepPage)
    this.deletePages({nStart: keepPage+1, nEnd: this.numPages -1});
    var keepPage=this.pageNum
    this.deletePages({nEnd: keepPage -1});
    Which worked, but would give a:
    TypeError: Invalid argument type.
    Doc.deletePages:8:App Delete_other_pages:Exec
    ===> Parameter nEnd.
    in the console if you were on page 1.
    Yours is clearly done by somebody who knows better. I'll put this in an AcroButton and be in business. Best.

  • Delete all users except one?

    hi there,
    I'm in a lab environment where I need to be able to delete all user accounts except "Administrator" on remote machines from ARD that accumulate from unsuccessful syncs, etc.
    Is it possible to run a selective rm -rf command that will do this? I've googled, but the solutions don't seem to work for me.
    Thanks!

    I found this article: http://snippets.dzone.com/posts/show/3908
    It says to use this command:
    find . ! -name "*.ogg" -exec rm -f {} \;
    Adapted for my purposes:
    find . ! -name "administrator" -exec rm -rf {} \;
    I tried this on a folder called "test" on my local machine with folders named 1, 2, and 3 (keeping 2) and it worked, but I want to make sure this is a good idea before I push it out via ARD to 90 workstations. Thanks!

  • Why is Address Book deleting all my contacts randomly?

    Hi,
    I've been using a 20" Intel iMac for about 2 years now, and I've loved it. However, after upgrading to Leopard in late May, and having my .mac account upgraded to MobileMe in July, my Address Book will randomly delete all of my contacts (over 700).
    Aside from the "panic" this causes, it also loses "My Card" which means iCal can't send email invites for meetings I schedule, auto-complete in Mail doesn't work, etc.
    I've Reset Syncing with MobileMe a number of times, and finally turned off syncing with MobileMe altogether. The problem is still happening. I've also re-installed Leopard using the Archive & Install option, Software Updated my system with all the patches and updates, restored an old Address Book archive -- I do weekly backups offsite -- and still the problem persists.
    The only thing I can find -- and which I am utterly incapable of doing anything about -- is a one-line entry in Console's Log files that reads:
    7/17/08 5:48:55 AM com.apple.launchd[511] ([0x0-0x96096].com.apple.AddressBook.abd[1820]) Check-in of Mach service failed. PID 1820 is not privileged: com.apple.AddressBook.abd
    Right after this scrolls by, I check my Address Book and sure enough...it's empty. What can I do about this?

    I have Backup 3 scheduled to backup my address book data files (and a number of others as well) every week, and store them out on my iDisk. When I realized my address book was empty, I used Backup to restore one of the older archives. Without that, I'm not sure what I would have done...
    For what it's worth, I have a little bit of new information to add to this story. As an experiment, I restored my backup and immediately exported my entire address book to a vCard file. The next time my data disappeared, I imported the vCard file instead of my address book archive. I lost all of my groups -- which is frustrating -- but so far, the actual contact data has remained in my address book for 5 hours. This is the longest by far...
    Interestingly enough, I'm still getting that weird error message in Console, but there used to also be messages about certain contacts not having meta data and certain contacts having meta data. Now, there is just the permissions error...no more complaints about meta data.
    Perhaps this is all just a bad coincidence with a corrupted address book data file, but still doesn't explain the Console error message. I'm going to keep experimenting until I either find a solution, someone here suggests a solution, or I simply give up out of frustration.

  • I can delete all photos except for one album where no trash can appears. How can I get rid of the album?

    I have an album of photos on my IPAD that I can not delete. It was imported from a camera card. I have managed to delete all other photos taken the same way but these appear to be stuck on the IPAD as no trash can icon appears. Also, my other photos appear in the imported folder and also albums. The photos in the album that won't delete only appear in that album?

    You would get more responses from iMovie users by posting in the iMovie community >  iMovie for Mac: iLife: Apple Support Communities

  • How i can keep password for some bookmark folders and delete all cookies excepting some?

    I want to have password for certain book mark folders before choosing them and I want to clear all cookies EXCEPTING SOME SITES, HOW I DO IT.

    You can't protect bookmarks with a password in Firefox.
    You can let all cookies expire if you close Firefox and make an Allow exception for the ones that you want to keep.
    *Tools > Options > Privacy > Cookies: "Keep until": "I close Firefox"
    *Tools > Options > Privacy > Cookies: "Exceptions"
    Make sure that you do not use [[Clear Recent History]] to clear the "Cookies" and the "Site Preferences" (Site Preferences includes the cookie exceptions)
    See also [[Cookies]] and [[Enabling and disabling cookies]]

  • Time Machine has deleted all backups except one..?

    (Snow Leopard 10.6.8) Mac Pro.
    I've been backing up for at least 2 years using Time Machine on an internal 500Gb drive. Today I get a message saying the drive is full and when I check all backups over the last 8 months (approx) have gone. The only backup surviving is the one it did just before the message popped up. Have tried Repair disk and Disk Warrior, but they're still gone. Is this most likely to be a failing drive issue? And is there any chance I can recover them?

    Time Machine will not delete your old backups unless it starts to run out of space on the hard drive......or.....your backups have become corrupted and Time Machine cannot repair them.
    In the latter case, a message like this will appear on your screen:
    Do you recall seeing this message recently?

  • Thunderbird deletes all emails at random times but is set to "never delete" them.

    It always deletes them when the program is closed and sometimes when it is minimumized. Also deleted them from the archives folder. Most seem to be in the "Trash" but not all. This started at the last upgrade.

    Ok is the account IMAP. That is the key.
    If you go to the troubleshooting information on the help menu and look at the mail and news accounts there will be either an IMAP, POP3 or SMTP entry for each account in the name.
    If it is imap, then the protocol is synchronized ie the imap phone, Thinderbird and what you do in your browser all replicate to one another.

  • I want to delete all cookies when I close Firefox except for one website. Is this possible?

    I have a website bookmarked that I use frequently and I have set my preferences on the site. I have Firefox set to allow cookies from this site. Is there any provision to delete all cookies except this site when i close Firefox?

    There is a plugin for that, search "cookie" on the plugins site and you'll find it.

  • Why won't preview let me delete all files (instead of all but one)

    In all OSX versions up to snow leopard in preview there was the option to select all open items and move the files to the trash. For some reason unknown to me, in 10.8.5 mountain lion that option no longer exists. Now preview lets me delete all files except one. If you have 2 images open you can move 1 to the trash. If you have 99 open you can move 98 to trash and if you have 1 open, you cannot move it to trash. Is there some code available where I can undo this restriction?

    Do you also have them on another computer, iPad or iPhone,  IF you do then it may be syncing them back

  • I want to delete all my bookmarks/favourites with on push of a button not individually.

    In the past I found a way to delete all the bookmarks at once to clean out the registry but can't remember how I did it and can't seem to find it in help. There must be an easier way rather than one by one. The deleting bookmarks section in help pages doesn't do it. I run Vista home premium
    Thank you.

    To reset the bookmarks to the handful of default bookmarks that come with a new installation, start Firefox in [[safe mode|Firefox safe mode]], then in the first dialog box that appears select the option "Delete all bookmarks except for backups" then click "Make Changes and Restart". All of your Firefox bookmarks will be deleted, but your browsing history will still be intact.

  • Delete command is not deleting all rows

    Hi All,
    Database version 10.2.0.2
    Delete command is not deleting all rows and deleting some subset of rows which it should delete, ever time I delete and do the roll back, next time it will delete some random rows, count is different everytime with in the range but not complete in anyway. see the following -
    select count(*) from test where evt_id in (select evt_id from test1);
    COUNT(*)
    27105
    delete from test where evt_id in (select evt_id from test1);
    16045 rows deleted.
    select count(*) from test where evt_id in (select evt_id from test1);
    11060
    rollback;
    Againg the same procedure -
    select count(*) from test where evt_id in (select evt_id from test1);
    COUNT(*)
    27105
    delete from test where evt_id in (select evt_id from test1);
    14320 rows deleted.
    select count(*) from test where evt_id in (select evt_id from test1);
    COUNT(*)
    12785
    why its not deleting all the 27k rows in one shot? Is there any bug related to that?
    Thanks
    Abhinav

    Odd that what looked like identical statements produced different results, both the counts and the deletes. The most likely cause of that is your data is changing - as Fahd suggested perhaps a simultaneous load taking place.
    The delete issue is probably not due to a bug. Possible but unlikely.
    If any evt_id values are NULL they won't be deleted with the subquery - a NULL in test.evt_id will never match a NULL in test1.evt_id.
    Have you tried alternative subqueries - a correlated EXISTS subquery for instance?

Maybe you are looking for

  • [CS3][VB] Bug in myPage.Duplicate :(

    hi I try to duplicate page and get reference to object on newly duplicated page I do something like this - this procedure should place page from multipage-PDF to Labeled Rectangle on duplicated page - next page: Set myDestObject = FoundItem b = 1 Do

  • No video on itunes

    I have purchased heaps of movies through the apple store, but can't play them on my computer....

  • Canon Mx310 failed scanning message

    Have not been able to scan documents from cannon mx310 since installing snow leopard. When scan button pressed a failed scan message appears and then it returns to previous screen.

  • Syntax error in IDoc segment

    Hi, when I make a syntax check on my Idoc segment '/FIT/E1FISFIINV'  I get the error message: Entries for segment '/FIT/E1FISFIINV' missing in the 'Segment structures' table. I can't delete the segment type as I get the error message Segment /FIT/E1F

  • Stop Right Clicks from automatically Opening link in new tab?

    So Normally I would right click a link, scroll down to "Open link in new tab" or "Open link in new Window" ect ect. But now, before I can choose which option I want (tab or window) it automatically opens the link up in a new tab. it does it for every