Simply delete all entries in a database.

Hello,
how do I simply delete all entries in a database (which must be thread safe, and most probably is)? For instance it is needed, as I'm developing a versioned open source XML/JSON database system, whereas I'm using a BerkeleyDB environment/database as a transaction log per revision (resource/log/version_number/...) for dirty blocks/pages and now want to introduce checkpointing (with currently only a single write-transaction per resource). That is another reading transaction (possibly another thread might read a transaction log, a BerkeleyDB environment/database while another thread, the checkpointer (most probably a deamon thread) commits, that is writes the log periodically or during less workload into the real resource. After the data is commited, the transaction-log must be emptied, but probably a reading transaction still reads from the log and falls back to reading from the real resource if the page is not in the log. That is I can't remove the database, but probably simply have to delete all entries and a simple .commit-file flag which indicates if the data has been written back to the real resource or the checkpointer must be writing it back sometime in the future (if the .commit-file still exists). Do I have to iterate through the database with a cursor (and .getNext())? Or does a dedicated method exist?
kind regards
Johannes

Hi Johannes,
As I think you've already discovered, there is no built-in method for deleting all records of a database that is open. The only similar built-in methods are those for removing or truncating an entire database (removeDatabase and truncateDatabase), and the database must be closed.
If you can't find a way to use removeDatabase or truncateDatabase, then you'll have to iterate through the records and delete them individually. If this is done for a large numbers of records in a single transaction, it will be expensive on a number of fronts, including memory usage for the locks: each record is individually locked.
If you don't need to delete all records in a single transaction (I couldn't completely understand your use case), then you can iterate with a cursor using READ_UNCOMMITTED and delete the records in individual transactions using Database.delete. This avoids using lots of memory for the locks, since only one record is locked at a time.
In either case the cost can be reduced by using DatabaseEntry.setPartial(0, 0, true) for the DatabaseEntry that is passed as the data parameter. You only need the key to delete the record, not the data, and avoiding a fetch of the data is a big cost savings (if the record data is not in cache). This optimization is only in JE 5.0 and above --in JE 4.1 and earlier, this has no advantage because the data is always fetched internally, as part of the deletion operation.
--mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Delete all entries from the following tables - Follow-up Activities (oracle)

    Hello,
    I performed a homogeneous system copy of our development BW system with the database (oracle 11.2.0.3) from the BW production system!
    I already start the oracle database and the SAP system in the target system/server (development BW system) and I´m doing some follow-up activities. One of this activities is (at the system copy guide 6.2.3.2 Activities at Database Level) is to delete all entries from the following tables:
    DBSTATHORA, DBSTAIHORA, DBSTATIORA, DBSTATTORA
    I tried to delete them using SQL Plus:
    sqlplus /nolog
    SQL> connect /as sysdba
    SQL> delete from DBSTATTORA;
    delete from DBSTATTORA
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ... and it show me that error message.
    This is strange because when I go to transaction SE14 and check the DBSTATTORA I see that table exist and contain a lot of entries!
    Why this is happened in SQL Plus!? I´m running the correct SQL statement for doing this type of task or not?
    How can I delete the entries of that tables? Can I do that using the transaction SE14?
    Can you help me please?
    Thank you,
    samid raif

    Hello
    sqlplus /nolog
    SQL> connect /as sysdba
    SQL> delete from DBSTATTORA;
    delete from DBSTATTORA
    ERROR at line 1:
    ORA-00942: table or view does not exist
    It doesn't surprise me as you are not mentioning the schema name here. Instead it should be
    delete from SAPSR3.DBSTATTORA;
    Assuming the schema owner is SAPSR3. if the owner is different then replace that with the correct one.
    Regards
    RB

  • BPM question - Delete all entries in a table and Insert data

    Hello,
    I'm new to PI BPM and have this scenario to implement.
    I'm supposed to delete all entries in a table and then insert data to the same table.
    Is BPM necessary? If it is, what is the best practice to implement my scenario?
    I want to make sure that all entries were successfully deleted before insert data.
    How do I check if all entries in the table were deleted successfully before
    initiating insert.
    Thank you.
    -Won

    Hi Won,
    Yes, this is possible without BPM.
    You have to create 2 separate mappings, each for deleting & inserting the records.
    You will have 2 different Interface mappings as well.
    But in ID, create a single interface determination.
    In that, configure Deletion interface mapping first and in the second row, configure Insertion interface mapping.
    Please make sure that the parameter 'Mainain Order At runtime' is checked in interface determination.
    -Supriya.

  • Delete all content in a database table

    i want to initialize a database table just before my specific program terminate.
    can i use the
    delete databasetable
    Edited by: Matt on Nov 7, 2008 8:04 AM

    Hi,
    If you want to delete all the contents of database table, use the following code:
    data itab type standard table of dbtab.
    select * from dbtab into table itab.
    delete dbtab from table itab.
    Hope this will help.
    Regards,
    Nitin.

  • II want delete all entries in shown by showjobs

    Hi,
    In my local machine, i want delete all entries shown by showjobs ( dveloppemnt suite version 10.1.2.0.2)
    http://localmachine.domain:8889/reports/rwservlet/showjobs?
    Thank's in adavance.

    Hi Salim,
    Metalink ID 260810.1 will serve your purpose,(For clear description,Explained well)
    Basically you can delete all entriesshown by showjobs
    By reducing maxQueueSize to 1 or 0 and restart the Reports Server, then reset maxQueueSize back to desired number and restart again.
    The maxQueueSize is a paramter present in rep_servername.conf file
    Hope this helps,
    Regards
    Fabian

  • How to delete all rows data from database

    Hello All.
    I have a database username 'abc'. This database contain 123 tables & have many data.
    I want to empty all the database. Is it possible that clear all the database with a single query.
    if yes then kindly tell me about the query .
    Thanks
    Diamond

    Keep in mind that you cannot rollback the truncate command.
    Once you truncate a table all of it's data AND statistics are gone.
    If you do not want to use PL/SQL to delete all rows you can generate a script by SQL
    SCOTT@ORCL> SELECT ' TRUNCATE TABLE '|| TABLE_NAME||';' FROM USER_TABLES;
    'TRUNCATETABLE'||TABLE_NAME||';'
    TRUNCATE TABLE BONUS;
    TRUNCATE TABLE SALGRADE;
    TRUNCATE TABLE DEPT_LOV;
    TRUNCATE TABLE TITLE;
    TRUNCATE TABLE TEST_DATE;
    TRUNCATE TABLE DEPT;
    TRUNCATE TABLE REP;
    TRUNCATE TABLE REP_PARAM;
    TRUNCATE TABLE EMP;
    10 rows selected.
    SCOTT@ORCL> SELECT 'DELETE FROM '|| TABLE_NAME||';' FROM USER_TABLES;
    'DELETEFROM'||TABLE_NAME||';'
    DELETE FROM BONUS;
    DELETE FROM SALGRADE;
    DELETE FROM DEPT_LOV;
    DELETE FROM TITLE;
    DELETE FROM TEST_DATE;
    DELETE FROM DEPT;
    DELETE FROM REP;
    DELETE FROM REP_PARAM;
    DELETE FROM EMP;
    10 rows selected.
    SCOTT@ORCL>You can save the output in a .sql file and run it.
    Regards,
    Tony

  • Deleting ALL keywords from Lightroom database?

    Hi, gang. I've been playing around with Lightroom and Bridge and I've realized that I got very deep into adding keywords in Lightroom but that I would much rather add them in Bridge, then import them into Lightroom. The problem is that I now have amassed a huge number of keywords that migrate into Bridge and that are time-consuming to change. I'd rather just delete every keyword in Lightroom at once, then re-create them in Bridge, and THEN import them into Lightroom.
    So, does anyone know if Lightroom has one specific file that it stores in a folder somewhere that I can just delete? If I have to go through and delete each keyword one at a time, I'll just uninstall Lightroom and reinstall it (unless there's also a way to dump my whole database and start again).
    Thanks for the help!
    -A

    >Does this not need confirmation on each keyword as you delete it?
    He's been polishing his crystal ball again ;-)
    The dialog will probably tell you that keyword X will be deleted from Y photos and give you the option to Cancel or Delete All. Chose Delete All and ALL selected keywords will be deleted. The dialog is either presenting the wrong info about what will be deleted or is deleting everything when it shouldn't. Strangely, had there been 100 selected keywords then you would need to hit Cancel 100 times.

  • The last Mountain Lion update simply deleted ALL contents from my downloads folder. Thank you very much, Apple.

    I updated my Mountain Lion yesterday with the latest system update and after reboot, much to my dismay, EVERY file I had on my downloads folder was permanently deleted.
    Months and months downloading research material for my business plan, all gone.
    Thank you very much, Apple.

    john --
    You're talking to other Mac users here, not "Apple."
    So, you do backup your HD regularly, right?  Just go there.

  • Need to read all entris  for field prtxt from table /sapsll/prt

    hi
    i need to read all entries from table /sapsll/prt field prtxt but only one is coming
    pls see below seelct statement
    if not gt_sagmeld[] is initial.
                SELECT /sapsll/cuit~guid_cuit         " PK
                       /sapsll/cuit~QUANT_FLT         " to be displayed
                       /sapsll/cuit~QUAUM             " to be displayed
                       /sapsll/cuit~RPTDT             " to be displayed
                       /sapsll/cuit~guid_cuhd
                       /sapsll/cuit~guid_pr           " needed for gt_prt inttab
                      /sapsll/corref~refno
                       /sapsll/corref~guid_pobj
                INTO corresponding fields of table gt_sapsllcuit
                FROM ( ( /sapsll/cuit
                inner join /sapsll/cuhd on /sapsll/cuit~guid_cuhd = /sapsll/cuhd~guid_cuhd )
                inner join /sapsll/corref on /sapsll/corref~guid_pobj = /sapsll/cuhd~guid_cuhd )
                FOR all entries in gt_sagmeld
                WHERE /sapsll/cuit~guid_cuit = gt_sagmeld-guid_pobj.
             endif.
            if not gt_sapsllcuit[] is initial.
             select /sapsll/prt~prtxt
                    /sapsll/prt~guid_pr       
             into corresponding fields of table gt_prt
             from /sapsll/prt
             for all entries in gt_sapsllcuit
             where /sapsll/prt~guid_pr = gt_sapsllcuit-guid_pr.
    loop at gt_sagmeld into wa_sagmeld.
    read table gt_sapsllcuit into wa_sapsllcuit
    with key guid_cuit = wa_sagmeld-guid_pobj
    binary search.
    Read table gt_prcon into wa_prcon with key
    guid_pr = wa_sapsllcuit-guid_pr.
    if sy-subrc = 0.
    *wa_sagmeld_outtab-guid_pr  = wa_prt-guid_pr. 
    here i am facing problem as multiple entries from table  /sapsll/prt is not being displayed only one.....but i have checked in table it is having two enteries
    pls suggest
    reagards
    Nishant

    Hi Nishant!
    When you use 'for all entries' SAP (or database?) does a 'delete adjacent duplicates' on the result. This is necessary because of the special selection technique in this case.
    You need to select enough columns from /sapsll/prt, so that your two entries will differ in the result.
    Regards,
    Christian

  • Need suggestions for concurrent reads while deleting all entities

    Hello,
    we need some suggestions for the following use case, as we cannot seem to find the correct transaction locking combination to meet our needs.
    We are using BDB JE 4.1.10, and the entityStore is transactional. In a nutshell, BDB JE is used as a Cache for specific data that is pulled and updated regularly from a source Oracle DB. The application that holds BDB is a realtimel app, and response time is critical.
    In order to avoid having to merge (Insert/update/delete) entities for some of the tables that are very static and small (a few hundred records that might change every day or so), we are trying to simply delete all records (with an EntityCursor loop, since there is no 'deleteAll' that we could find) and reinsert all data every 5 minutes, and then committing when the whole process is complete. This should always be very quick, but we are not immune to timeouts from the source Oracle DB, so the transaction can be long.
    Ideally, while the delete/insert is happening, we want any concurrent read operations to return the old data (before the delete). We have made a test that locks the updater thread between the 'delete all' and 'update all' methods, so that the delete cursor is closed, but the Tx is not yet commited. We have tried the following for our reader thread:
    1- If we get() a deleted entity with a LockMode.READ_UNCOMMITTED, we get a null entity back.
    2- If we get() a deleted entity with LockMode.READ_COMMITTED, we get a LockTimeoutException.
    We have also considered simply using truncate on the EntityStore, but this requires closing and reopening the DB, so this would not work for our need to always return a value, instantly.
    Any ideas, suggestions on how we could do this in a simple manner?
    Thanks,
    Max

    Hello Max,
    I understand the issue you're describing.
    I think the best performing solution by far is to load the new data into new databases while servicing reads from the old databases. When the load is complete, reads can be diverted to the new databases, and the old databases can then be removed.
    Unfortunately, this is easier to do with the base API than with the DPL, because the DPL is managing the underlying (base API level) databases for you.
    However, even using the DPL, this approach could be very straightforward if you happen to be keeping this data set (the one that needs to be reloaded) in a separate EntityStore, or you can change your application to do so. If so, you can create a new (empty) EntityStore with a different name and use this store for loading the new data. When the load is complete, divert reads to the new EntityStore object and remove all databases for the old EntityStore.
    If this is impractical, please explain, and I'll try to suggest a different solution. If you cannot use a separate EntityStore for this particular data set, then the solution may be more complex.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How can I find all exclamation marks in my iTunes without clicking on each song?  Is there a way to delete all instead of one at a time?

    How can I find all exclamation marks in my iTunes without clicking on each song?  Can they be deleted all at once instead of one song at a time?

    Lost & Found
    Create a playlist called Found, select everything in Music and drag it into the Found playlist (it may take some time to count the tracks that are to be dropped). Create a smart playlist called Lost matching All the rules Playlist is Music and Playlist is not Found. Your lost tracks will be in this playlist.
    Optional: It depends a bit on why things aren't where iTunes expects to find them but if they are in sensible Artist & Album folders in some common location then my FindTracks script should be able to reconnect them to iTunes. FindTracks uses some fuzzy matching routines and searches for multiple potential locations. For more details see this thread. Once you have repaired the tracks that can be found you can drag the contents of the Lost playlist into Found which will update things.
    Or, you can simply delete all the tracks in the Lost playlist with Ctrl-A to select them and then Shift-Delete to delete.
    tt2

  • Repeating successful uploads - procedure to delete all the requests/packets

    Hi friends,
    I have a sort of hypothetical question, so never mind if this makes sense in real life (actually, I can think of a few situations where it makes sense, but only as a last resort).
    Let's say I want to repeat the upload that was successful (request is green in the cube). Or another point of view, let's say I want to delete all successful uploads except the initial one. The load is delta load and straight from R/3 into the cube (no DSOs or other objects in between).
    What do I need to do/check? I obviously need to delete the requests in the cube, but where else can the data be stored? PSA is probably the first place to check, but it seems to be empty most of the times. How do I delete all the data from the PSA? The BI delta queue is always empty when I look at it from the Administration menu. Again, must I delete it and how? I guess I should delete the delta queue in R/3 as well (through SBIW)?
    How do I do the same thing when there ARE other objects (like DSOs) before the cube?
    Thanks in advance for your advice/help.
    Kind regards,
    K.

    Probably it does not )
    Anyway, i was thinking of a hypothetical situation where an administrator accidentally repeats an upload at some point and thus doubles the figures. Then he does not notice it immediately and the system keeps loading requests for some time.
    I actually wanted to predict a solution to this problem, since it would be difficult (if not impossible) to find the duplicate records, especially after "compress". I thought that simply deleting all the requests and reloading through normal delta would solve this hypothetical situation. But again, where and how to delete all (and be sure you deleted all) to ensure that the records will not be doubled.
    K.

  • Regenerate all entries in tab InfoSource through tcode RSA1

    Dear !
    I am having a problem with tab InfoSource of Modeling in NW 7.0 EHP1 system through
    Tcode RSA1. I have already installed a new NW 7.0 EHP1 system (new system
    - no data)
    My apprentice already deleted all entries in tab InfoSource of Modeling. Now tab
    InfoSource empty
    My apprentice already deleted following:
    Nodeling -> InfoSource -> Delete Technical Content and delete all entries in Unassigned Nodes
    I want to regenerate all original entries in tab InfoSource. How ?
    Please help me
    Thanks and best regards
    Edited by: myfriend280985 on Jan 31, 2010 6:23 AM

    I'm not sure if your are talking about Technical Business Content. If so it seems you have to re-activate it from Business Content.

  • Deletion of entries from a table whose name is controlled by Z program.

    Hi all,
    I have to delete all entries in a custom table whose "Name" has a certain pattern say ZDBTAB01, ZDBTAB02, etc.
    I arrive at the table name through ABAP code. But the statement
    "DELETE FROM tab_name" doesnot work where tab_name is a variable.
    Can anyone suggest a function module to perform this action..??
    Thanks.
    Regards,
    Senthil G.

    data : v_tabname ..... value 'ZXXX'
    delete from (v_tabname).
    It should work. Are you getting any error message as such.

  • Want to delete all iCloud files but not close accout

    I uploaded many items when I first created my iCloud account, but now realize I only want certain items there.  How do I delete all my iCloud data without canceling my iCoud account so I can start over?

    Simply delete all your contacts from address book, calendars from iCal etc etc, anything you remove from one device will be removed from the iCloud and all other devices.

Maybe you are looking for