SQL & PL/SQL :: Retrieve Deleted Rows
Jun 13, 2013how to retrieve deleted rows in oracle?
View 7 Replieshow to retrieve deleted rows in oracle?
View 7 Repliesdeclare
min_as_of_dt date;
max_as_of_dt date := to_date('30-SEP-2012', 'DD-MON-YYYY');
begin
DBMS_OUTPUT.ENABLE(10000000);
[code]......
Problem: rows are not getting deleted after running this script.
My table "xxbuyer_det" contains the below data.
buyer_id Invoice_numPriceItem
------------------------------------
148137110A
149314211B
149314315C
149314415F
148120520D
148120625E
My requirement is to select the rows which have same buyer_id more than or equals to two times (>=2). I am trying with the below query. But this query is failing(not retrieving any data) as i have used group by class and count value is 1 for every record.
SELECT BUYER_ID, INVOICE_NUM, PRICE
FROM
xxbuyer_det
GROUP BY
BUYER_ID,
INVOICE_NUM,
PRICE
HAVING COUNT(*) >=2
How to retrieve duplicate rows from a table, suppose i don't know any column names. Without hard-coding column names I need to find.
View 5 Replies View RelatedI have created a table called ct_temp and it's structure is:
create table ct_temp(id char(2),srs number(3),amt number);
Result : Table Created
I now insert the following rows into the table:
id srs amt
1 62 30000
2 65 50000
3 65 70000
4 65 80000
5 62 16000
6 65 10000
7 65 100000
8 65 10
Commit
Then I issue the following query to retrieve data based on a specific criteria (Actually I have condensed the table and data because in Production, I have large number of rows; so for simplicity I am using 8 rows with one table)
criteria : I then want to retrieve the following:
for srs = 62, all values that is greater than 10,000
Answer: select decode(srs,62,ab.amt)temp1 ,decode(srs,65,ab.amt)temp2 from ct_temp ab
where decode(srs,62,ab.amt)>10000
Works like a charm and retrives the results.
Now comes the big issue
I want to retrieve the values for srs = 62 which is greater than 10,000 and at the same time I also want to retrieve the values for srs = 65 which is less than srs = 62.
Typically I wrote the query as:
select decode(srs,62,ab.amt)temp1 ,decode(srs,65,ab.amt)temp2 from ct_temp ab
where decode(srs,62,ab.amt)>10000
and decode(srs,65,ab.amt)<decode(srs,62,ab.amt)
I should atleast get one row for srs = 65 which is id # 8 but it displays blank rows or "no rows returned".
I am actually preparing a ad-hoc report for the business analyst and stuck at this step due to which I am unable to proceed any further. I have used DECODE function because of the requirement specified by Business Analyst.
I have tried the following in the office:
using EXISTS operator = no luck
using INLINE VIEW = no luck
Is there any way around?
I have two tables which have identical schemas, one table (tbl_store) is used to hold the latest version, and the other table (tbl_store_audit) holds previous versions. When the latest record is updated, it is inserted into the tbl_store_audit table as a revision, and the updated details are used as the latest record.
For example: The latest version is held in tbl_store, however the tbl_store_audit may hold 5 records which are the past records used before changes were made - these are seen as revisions.
I want to be able to compare what has changed between each revision in the tbl_store_audit table. For example: Out of the 10 columns, the change between revision 1 and revision 2 was the size from XL to XXL. The change between revision 3 and revision 4 was the size XS to M and price 4.99 to 10.99, and so on.
Eventually i will create an APEX report that will show the user the revision number and what was changed from and to.
I seen in a previous post i need to note my oracle version: Oracle version 10.2.0.4.0
I am trying to retrieve all rows with the date of May 23rd, 2008. Our data is stored with the date and time.
How do I format the where clause so that the time is taken off? I am still a newbie with oracle and what I have is this:
Select Distinct Table1.*, Table2.*
from Table1, Table2
where Table1.file_name = Table2.file_name
and Table1.downloaded_date = Table2.date_loaded
and downloaded_date = '23/May/2008'
Of course, it's the last line not working because I don't know how to format it and no rows are retrieved when there are definately May 23rd rows stored in there.
I need a generic query to generate total # of records for each table in a schema, total # of records that are not null for each column in the table, and total # of records that are null for each of those columns in those tables.
ex:
the output should look like this.
owner schema table_name total# recs in the table, column_name,
------ ------ ---------- ------------------------- -----------
# of records not null # of records null
---------------------- --------------------
I have a major problem my oracle_home/bin directory was delete mistakenly by on of our user. Because i cannot use all oracle utitilessqlplus,dbca,netca,netmgr. how do i the cover this problem?
View 2 Replies View Relatedi want to insert values in another table whatever i deleted. i don't want whole information like backup, i just want deleted information only. whenever any 1 will try to delete any information on my database ,easily i would get to know what,when he has deleted .
View 14 Replies View Related1)How can i know that in a table when i modified a row or deleted a row and which row i inserted when i want to know the particular time
can it is possiable if possiable then tell me how.
2)Is there any difference between 9i merge and 10g merge command ?
I have deleted all the records from the table.And I have committed.Now I want to get all the records back.
View 16 Replies View RelatedHow to find out the tables that are frequently getting deleted?
View 2 Replies View RelatedI deleted a table in oracle sql 11g about two weeks ago and commited. Didn't realise that I would need it later on and now I needed. is there a way a can get reverse this.
View 13 Replies View RelatedI am new to oracle database. I wanted to know if it is possible to recover a deleted column of a table. If yes, how can it be done? I tried flashback but it seems that flashback doesn't support recovery of deleted column.
View 2 Replies View RelatedI am executing a script that is deleting some parent records and the corresponding child records as I have used the "on delete cascade" with the Foreign key Constraint.
My question is that can I list the records that are being delete from all the tables i.e. both parent and child tables. Is some thing like spooling can work in this or do I have some other option with which I can see(select) all the deleted records.
Somebody deleted records from 10,12 tables in one of the schema. I found in one of the forum that table can be restored also if it exists in the recycle bin. I checked by querying:
select object_name, original_name, type, can_undrop as "UND", can_purge as "PUR", droptime from recyclebin;
> select type, can_undrop as "UND", can_purge as "PUR", droptime from recyclebin WHERE TYPE='TABLE' and droptime like '%2012-07-31%';
PHONE TABLE YES YES 2012-07-31:10:23:08
TABLE YES YES 2012-07-31:10:23:08
TABLE YES YES 2012-07-31:10:23:08
TABLE YES YES 2012-07-31:10:23:08
TABLE YES YES 2012-07-31:10:23:08
- -
- - I created a test table and dropped it and restored from recycle bin using following flashback table test query....but in my case tables are not dropped...these tables are shoing 0 records. How can I recover only records from recycle bin tables?
SQL> flashback table test to before drop;
Flashback complete.
DB=10.2.0.5 on RHL
I have a trigger which monitors the deletion activity on the table. But I would like to re-insert those records to the in the table using the same trigger.
View 1 Replies View RelatedI am trying to create a trigger to stop events from being deleted if the date is before the current date. This is the SQL syntax for my table
CREATE TABLE event
(event_id numeric(5) not null,
concert_id numeric(5) not null,
event_date date,
);
What I have attempted so far is:
CREATE OR REPLACE TRIGGER event_deleting
BEFORE DELETE ON event
FOR EACH ROW
BEGIN
IF DELETING THEN
[code]......
This gives me a few warnings, the first is that a DECLARE is missing and the second is a INTO is missing.
A full, online backup (database, archived redo logs, and control file autobackup) is done with rman ("nocatalog", Oracle 9i on AIX 5.2) daily. A media manger is not in use, so the backup is written to disk, then written to tape using an operating system utility. There is room on disk for two full backups, so "redundancy = 1" and obsolete backup sets are deleted to free up space immediately before running the next backup. If the backup(s) on disk are lost and the tapes containing these backups are lost, will it be possible to restore a tape containing older "deleted" backups (using an operating system utility) and catalog each backup piece in the current control file? In other words, can backups considered "deleted" in the control file be reintroduced if they're available on tape?
View 4 Replies View RelatedHow to avoid this error. FRM 40102 Records must be inserted or deleted first
i have used next_record.If i remove this it is working.but i need to use next_record built in.
I'm getting below error. how can we avoid this error?
ERROR: frm-40102 record must be entered or deleted first
### Changes made ###
1 week before we did a change on tablespace segment management - from MANUAL to AUTO by following method:
1. create INVD2 & INVX2 & LOBD tablespace.
2. Move TABLE from INVD to INVD2.
3. Rebuild INDEX from INVX to INVX2.
4. Move LOBSEGMENT from INVD to LOBD tablespace.
5. After confirm no segments exist in old tablespace, offline and drop INVD & INVX.
6. Change default tablespace for INV user to INVD2.
7. RENAME TABLESPACE INVD2 to INVD, INVX2 to INVX.
8. Change default tablespace for INV user to INVD back.
9. Run Gather Schema Stat for INV using UNIX scheduler which work usually. However, error ended with ORA-03113 & ORA-03114.
10. Manual execute with same statement the following day, procedure completed successfull.
After 1 week later, inventory forms detected error FRM-40735 in all forms. Checked the gather schema stat job was run in the morning before user feedback..
AFter refer notes from metalink, I understand this is a bug where RENAME of the tablespace could not rename as the previous one, as the deleted entry is still exist in sys.ts$?
There is no segments exist in the deleted tablespace, or any user default tablespace is assigned to the deleted tablespace.
My Question:How can we delete the deleted entry from sys.ts$?And should we rename the tablespace from INVD to INVD3 (or can we use back INVD2) to avoid any unforseen error again?
Is there any way I can find out what caused the database to crash; either a history of commands executed within the database, I lost my bdump directory before the scheduled backup ran and the only logs available are after I re-created the directory.
SQL> startup
ORA-00444: background process "PMON" failed while starting
ORA-07446: sdnfy: bad value '' for parameter .
SQL>
[code]....
I ran into the message RMAN-08138: WARNING: archived log not deleted - must create more backups during a backup. From what I understand this is caused when logs are removed that are needed for recovery.
rman target / nocatalog <<EOT
CONFIGURE CHANNEL DEVICE TYPE DISK clear ;
CONFIGURE CHANNEL DEVICE TYPE TAPE clear ;
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' clear ;
CONFIGURE RETENTION POLICY TO recovery window of 14 days;
CONFIGURE BACKUP OPTIMIZATION OFF;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
[code].....
A datafile was deleted from a partitioned table which has 31 partitions , that datafile contains data from day 25 to day 31 st I am not having a backups of this database. but I have all the dumps of that table what is the solution to get those 6 partitions data back.
View 9 Replies View RelatedThe SQL Query portion of Authorization Schemes are deleted or set to NULL after editing. Re-entering the SQL Query will not save the SQL, so the SQL Query is lost.
I had to update WWV_FLOW_SECURITY_SCHEMES.ATTRIBUTE_01 via sql to restore and modify the SQL Query portion of the Authorization Schemes.
I'm trying to create a trigger so that whenever a record in the Employee table is deleted, a trigger will automatically delete corresponding records in the Job History table, then the Employee record is archived to EmployeeArchive before it is deleted. It compiles but with warnings. Here's what I've got.
CREATE TABLE EmployeeArchive
(EmployeeID Int, FirstName Char, LastName Char,
EMail Char, PhoneNumber Int, HireDate Date, JobID Char, Salary Int,
Commission Int, ManagerID Int, DepartmentID Char);
[Code]....
version: 10.2.0.4
OS: windows server 2003
I am not able to delete one month old archive log file manually on windows which doesn't having info about the standby on v$archived_log view of primary database. the sequence were already applied to the standby database. It shows the status as deleted in v$archived_log. while deleting the file manually. it showing an error like another program or person is using it.
Operating System - WindowXP
oracle version 10.2.0.1
I was learning some recovery part in my home laptop. Database is in Archivelog, flashback mode. All of sudden, i deleted it from OS level with out taking backup of it.
When i tried to open database, it failed to start. Database is in mount mode.while trying to open, it gives message -
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: 'F:ORACLEPRODUCT10.2.0ORADATADBSYSTEM01.DBF'
I tried to create on file named "UNDOTBS01.DBF" but oracle is not recognizing it.