Search This Blog

Showing posts with label oracle. Show all posts
Showing posts with label oracle. Show all posts

Monday, March 9, 2020

Procedure of updating oracle parameters in spfile



Oracle has two parameter files from which it reads while it's beginning .

They are spfile (server parameter file) and pfile (parameter file). Spfile is binary format file where manual changes are not allowed.
Below document shows us the procedure on the way to change/update the oracle parameters in spfile.

This procedure is on linux operating system.



Take a backup of pfile and spfile







Create pfile from spfile
























Make the changes to the pfile by editing the file
The init<orasid>.ora file has been edited by inserting the required  parameters

























Stop SAP only










Shutdown DB










Startup Database in mount state by giving the pfile path










Create spfile from pfile








Shutdown DB













Start DB


'









Start SAP


Monday, February 13, 2012

Oracle shutdown types

During a normal shutdown, Oracle closes all sessions . closes the database, un-mounts the data files then shut down the instance in two steps, first issuing a "free" the SGA RAM heap and eventually , terminating the background processes.

Oracle has three shutdown modes:

Normal (default) - waits for in-flight work to finish . This could take houes.

Immediate - terminates all sessions and rollbacks all uncommitted transactions. 

Abort - it aborts all sessions, leaving current DMLs for rollback and de-allocates the SGA terminating all the background processes. Note that a shutdown abort isn't dangerous. The "abort"  means Oracle will terminate all active work, which is what most of the people want during a shutdown!

The "normal" and "immediate" modes can take an extended time in you've got in-flight transactions, and lots of Oracle DBA's ensure a swift clean shutdown this manner , aborting the sessions, re-starting to allow warmstart rollback of the aborted transactions, and a shutdown immediate to shut cleanly:

SQL> shutdown abort
SQL> startup
SQL> shutdown immediate


Normal Shutdown:
A normal shutdown of an Oracle database is really rarely used. This is because the normal shutdown waits for everybody to finish their work then logoff in an orderly fashion. When a normal shutdown occurs, the database is closed in a normal manner, and all changes made within the database are flushed to the database datafiles . This is known as a “clean shutdown.”

It will simply wait forever until we  kill those sessions manually. Because of this, we frequently recommend the shutdown immediate or shutdown abort commands, which we'll discuss within the next sections. Below is the syntax for the utilization of the normal shutdown command.

SQL> shutdown

When shutdown is executed , Oracle flushes all the changes in memory out to the database datafiles . This makes database startup quicker because the database is during a consistent state.

 A clean shutdown is one that's prepared to return copy at once . A dirty shutdown is one that lands on its back; it can't come up without first recovering itself.

Shutdown Immediate:
Perhaps the simplest way to initially shutdown the database is that the shutdown immediate command. This command will prevent any new logins, then rollback any uncommitted transactions, then bring down the database. In the process of bringing down the database, Oracle will flush all the changes in memory bent the database datafiles too, a bit like a daily shutdown does. This makes database startup quicker. Below is the syntax for shutting down a database with the shutdown immediate command:

SQL> shutdown immediate

usually shutdown immediate command will work mostly, but some times when it can hang and fail to shutdown the database. In these cases, the shutdown abort command is named for.

Shutdown Abort:
The shutdown abort command is just about a guaranteed way to get your database to shutdown. It’s a “hard crash” of the database, and this will end in a extended time to start out the database copy .  you aren't really hurting the database using the shutdown abort command, and through your DBA years you'll find quite a couple of occasions to use the shutdown abort command.

A shutdown abort are often your first shutdown method of choice, since there could also be times once you must force the database down. below is the syntax for using the shutdown abort command:

SQL> shutdown  abort

Saturday, July 30, 2011

Locating duplicate rows when trying to create UNIQUE INDEX

Presume you are trying to create a UNIQUE index on a column and get the following error:

SQL> desc emp
    Name                            Null?    Type
    ------------------------------- -------- ----
    EMPNO                                    NUMBER(15)
    NAME                                     VARCHAR2(20)
    DEPTNO                                   NUMBER(15)

   SQL> CREATE UNIQUE INDEX emp_i ON emp (empno);
   CREATE UNIQUE INDEX emp_i ON emp (empno)
                             *
   ERROR at line 1:
   ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found

Above error is encountered as Oralce couldn't create a UNIQUE INDEX on the table as it found duplicate records while trying to create the index. You know have to find the duplicate values. Below methods will be useful for locating duplicate rows in a table.

    Method #1 uses a self-join query. Oracle tables Consistently have one guaranteed unique column, the rowid column. Use of the MIN and MAX functions against the rowid column can easily display the duplicate rows.
    Method #2 uses a GROUP BY / HAVING query on the table.
    Method #3 uses the "exceptions into" clause of the alter table command. We need to first create the EXCEPTIONS table by running the script "utlexcpt.sql" inorder to use the "exceptions into" clause . On NT, this script is in your ORACLE_HOME/rdbms(73/80)/admin directory: On UNIX, it is in $ORACLE_HOME/rdbms/admin directory.

    Method #1 : Using a self join

    SELECT
          rowid
        , empno
        , name
      FROM emp a
      WHERE a.rowid > (SELECT MIN(b.rowid)
                       FROM emp b
                       WHERE b.empno = a.empno);

      ROWID                   EMPNO NAME
      ------------------ ---------- --------------------
      0000059F.0001.0001        100 Jeff

    Method #2 : Using a GROUP BY

    SELECT 
          COUNT(*)
        , empno
      FROM emp
      GROUP BY empno
      HAVING COUNT(*) > 1;

        COUNT(*)      EMPNO
      ---------- ----------
               2        100

    Method #3 : Using the "into exceptions" clause

    ALTER TABLE emp
      ADD CONSTRAINT emp_i UNIQUE (empno)
      EXCEPTIONS INTO exceptions;

      alter table emp
      *
      ERROR at line 1:
      ORA-02299: cannot enable (OPS$ORACLE.EMP_I) - duplicate keys found

      -- NOW JOIN THE exceptions TABLE TO THE emp TABLE BY rowid

      SELECT 
          a.empno
        , a.name
      FROM 
          emp a
        , exceptions b
      WHERE a.rowid = b.row_id;

           EMPNO NAME
      ---------- --------------------
             100 Mark
             100 Jeff