Difference between revisions of "Oracle"

From database24
Jump to navigation Jump to search
Line 2: Line 2:
  
 
== Configuration ==
 
== Configuration ==
 +
 +
=== Processes ===
 
* ORA-12516: TNS:listener could not find available handler with matching protocol stack
 
* ORA-12516: TNS:listener could not find available handler with matching protocol stack
 
** Edit %oracle_home%/database/init<SID>.ora
 
** Edit %oracle_home%/database/init<SID>.ora
 
** Add
 
** Add
 
  PROCESSES=200
 
  PROCESSES=200
 +
 +
=== Flashback ===
 +
In order to make use of something like
 +
<syntaxhighlight lang="sql">
 +
FLASHBACK TABLE MYTABLE TO TIMESTAMP TO_TIMESTAMP('2010-12-31 23:59:59');
 +
</syntaxhighlight>
 +
it is necessary to enable row movement.
 +
  
 
== FAQ ==
 
== FAQ ==
Line 31: Line 41:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== How do I rollback? ===
+
=== How do I rollback to a previously specified point? ===
 
<syntaxhighlight lang="sql">
 
<syntaxhighlight lang="sql">
 
SAVEPOINT MYSAVEPOINT;
 
SAVEPOINT MYSAVEPOINT;
 
-- ...
 
-- ...
 
ROLLBACK TO MYSAVEPOINT;
 
ROLLBACK TO MYSAVEPOINT;
 +
</syntaxhighlight>
 +
 +
=== How do I rollback to a certain time? ===
 +
<syntaxhighlight lang="sql">
 +
FLASHBACK TABLE MYTABLE TO TIMESTAMP TO_TIMESTAMP('2010-12-31 23:59:59');
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 23:23, 17 June 2011


Configuration

Processes

  • ORA-12516: TNS:listener could not find available handler with matching protocol stack
    • Edit %oracle_home%/database/init<SID>.ora
    • Add
PROCESSES=200

Flashback

In order to make use of something like

FLASHBACK TABLE MYTABLE TO TIMESTAMP TO_TIMESTAMP('2010-12-31 23:59:59');

it is necessary to enable row movement.


FAQ

How do I realize an auto-incrementing field?

CREATE TABLE    MYTABLE (
                ID          NUMBER(11, 0)   NOT NULL 
           -- , FIELD       
                );

CREATE SEQUENCE MYTABLE_ID_SEQ
    START WITH 1 
    INCREMENT BY 1 
    NOMAXVALUE; 

CREATE TRIGGER MYTABLE_ID_TRG
    BEFORE INSERT ON MYTABLE
    FOR EACH ROW
    BEGIN
        SELECT MYTABLE_ID_SEQ.NEXTVAL 
          INTO :NEW.ID 
          FROM DUAL;
    END;

How do I rollback to a previously specified point?

SAVEPOINT MYSAVEPOINT;
-- ...
ROLLBACK TO MYSAVEPOINT;

How do I rollback to a certain time?

FLASHBACK TABLE MYTABLE TO TIMESTAMP TO_TIMESTAMP('2010-12-31 23:59:59');