Monday, January 25, 2021

Oracle 19c Features

 *** Root Scripts Automation Support

*** Rac Desupported Features

*** Rac Deprecated Features

*** Dynamically Change Oracle Data Guard Broker Fast-Start Failover Target

*** Export and Import the Dataguard Broker Metadata File

*** New commands to set database initialization parameters in Dataguard Broker Configuration

*** New Features Automatic Database Diagnostic Monitor (ADDM) Support for PDB Database

*** Changes In Oracle Database Release 19c

*** Dataguard New Features



*** Automatically Deleting Flashback Logs

*** Tuning Automatic Outage Resolution With Data Guard

*** Restore Point Replication From Primary To Standby

*** New Features Data Pump-Test Mode For Transportable Tablespaces

*** dbms_auto_index

*** dbms_auto_index_internal

*** DBMS_SQLQ

*** dba_auto_index_config

*** dba_sql_quarantine

*** V$SQL_TESTCASES

*** DBA_REGISTRY_BACKPORTS


Thursday, August 2, 2018

performance with Result Cache in Oracle 11g


Oracle introduced the memory structure called Result Cache to store the results of SQLs & PL/SQL.
The database serves the results for the executed SQL queries and PL/SQL functions from the result cache instead of re-executing the actual query,
quite obvious this feature will increase the performance.
Memory allocated(can be controlled using RESULT_CACHE_MAX_SIZE parameter) for the result cache is taken from the shared pool.
By now one might come to the conclusion that result cache will improve the performance of the repeatly used PL/SQL & SQL.
RESULT_CACHE_MAX_SIZE specifies the maximum amount of SGA memory (in bytes) that can be used by the Result Cache.
If the value of this parameter is 0, then the result cache feature is disabled.

SQL> select name,value from v$parameter where name like 'result_cache%';

result_cache_mode                                                                MANUAL
result_cache_max_size                                                            0
result_cache_max_result                                                          5
result_cache_remote_expiration                                                   0

RESULT_CACHE_MODE:
   RESULT_CACHE_MODE specifies when a ResultCache operator is spliced into a query's execution plan. If set to FORCE,
   all the queries are cached if they are qualifed and fit in cache.
   The default is MANUAL, which indicates that only queries with the hint will be cached.
 
RESULT_CACHE_MAX_SIZE:
 
   Specified maximum size of the result cache. Remember, result cache is part of shared pool and maximum can be of 75% of shared pool size.
   Also query result.
 
RESULT_CACHE_MAX_RESULT:

       Specifies percentage of RESULT_CACHE_MAX_SIZE that any single query result set can occupy.
       (Just to prevent the big result set from throwing out all other small resultset).
     
RESULT_CACHE_REMOTE_EXPIRATION:

  Specifies the number of minutes that a cached result that accesses a remote object will remain valid.
  Setting this parameter to 0 implies that results using remote objects should not be cached.
  Setting this parameter to a nonzero value may produce stale answers
  (for example, if the remote table used by a result is modified at the remote database).
  I personally think it should be set to positive value if remote database is read only database.
 
SQL> select * from v$sgastat where pool='shared pool' and name like 'Result%';

POOL         NAME                            BYTES
------------ -------------------------- ----------
shared pool  Result Cache: State Objs         2896
shared pool  Result Cache: Memory Mgr          200
shared pool  Result Cache: Cache Mgr          5552
shared pool  Result Cache: Bloom Fltr         2048

Like almost all memory structure in oracle instance,
Result cache is also protected by latches.
Latches, being serialization devices, are scalability inhibitors. Don’t just to come to conclusion that Latches are evil


SQL> select * from v$latchname where name like 'Result Cache%';

    LATCH# NAME                                                                   HASH
---------- ---------------------------------------------------------------- ----------
       391 Result Cache: RC Latch                                           1054203712
       392 Result Cache: SO Latch                                            986859868
       393 Result Cache: MB Latch                                            995186388


SQL> exec  DBMS_RESULT_CACHE.MEMORY_REPORT("TRUE")
R e s u l t   C a c h e   M e m o r y   R e p o r t
[Parameters]
Block Size          = 1K bytes
Maximum Cache Size  = 5248K bytes (5248 blocks)
Maximum Result Size = 262K bytes (262 blocks)
[Memory]
Total Memory = 2400 bytes [0.001% of the Shared Pool]
... Fixed Memory = 2400 bytes [0.001% of the Shared Pool]
....... Cache Mgr  = 152 bytes
....... Memory Mgr = 200 bytes
....... Bloom Fltr = 2K bytes
....... State Objs =  bytes
... Dynamic Memory = 0 bytes [0.000% of the Shared Pool]

PL/SQL procedure successfully completed.

SQL> exec DBMS_RESULT_CACHE.flush;

PL/SQL procedure successfully completed.

DBMS_RESULT_CACHE package has lot more functions/procedures and if you are looking for more, login into 11g using SQL* Plus and execute “desc DBMS_RESULT_CACHE” and the documentation for the same can be found here.

Background Process

SQL> select description from V$BGPROCESS where name like 'RC%';

    LATCH# NAME                                                                   HASH
---------- ---------------------------------------------------------------- ----------
       391 Result Cache: RC Latch                                           1054203712
       392 Result Cache: SO Latch                                            986859868
       393 Result Cache: MB Latch                                            995186388

Friday, February 16, 2018

Virtual Columns in Oracle 11g

create table marks
 (
    physics      number,
    chemistry       number,
    total     number,
    aggre  varchar2(6)
    generated always as
    (
       case
          when total <= 50 then 'LOW'
          when total > 60 and total <= 80 then 'MEDIUM'
          when total > 81 and total <= 99 then 'HIGH'
          else 'ULTRA'
       end
     ) virtual
 );



 insert into marks (physics, chemistry, total) values (50,60,40);


 insert into marks (physics, chemistry, total) values (60,70,60);

 insert into marks (physics, chemistry, total) values (80,95,99);

commit;




12:45:32 SQL> select * from marks;

   PHYSICS  CHEMISTRY      TOTAL AGGRE
---------- ---------- ---------- ------
        50         60         40 LOW
        60         70         60 ULTRA
        80         95         99 HIGH


create index IN_TOTAL on marks (aggre);


select index_type from user_indexes where index_name = 'IN_TOTAL';


12:47:52 SQL> select index_type from user_indexes where index_name = 'IN_TOTAL';

INDEX_TYPE
---------------------------
FUNCTION-BASED NORMAL


12:48:25 SQL> select column_expression from user_ind_expressions where index_name = 'IN_TOTAL';

COLUMN_EXPRESSION
--------------------------------------------------------------------------------
CASE  WHEN "TOTAL"<=50 THEN 'LOW' WHEN ("TOTAL">60 AND "TOTAL"<=80) THEN 'MEDIUM' WHEN ("TOTAL">81 AND "TOTAL"<=99) THEN 'HIGH' ELSE 'ULTRA' END

Wednesday, November 22, 2017

Oracle 18c New Features

Oracle 18c is Worlds first autonomous database cloud.It has designed to reduce complexity of  database,less  human errors. It also helps to ensure high reliability,security in optimal cost.This version is also used to reduce the Operational cost.

1.Oracle 18c uses adaptive machine learning which will reduce the human errors.

2.It reduces the complexity of database

3.It is highly relible and secure database

4.It reduces the operational cost

5.Self Driving database

6.Self Tuning database

7.Most efficient consumption of resources

8.Less human intervention

9.No downtime required for upgrades,patching or adding storage capacity.

10.It eliminates the costly downtime

11.Self Tuning uses adaptive machine learning which automatically activates caching,indexing,storage of indexes

12.It avoids costly overprovisioning.

13.It also helps to cut the labour cost as Oracle 12c is automated self driving database.

14.Oracle 18c is less expensive than AWS (Amazon Web Services).

15.All database maintenance tasks will be done without human interventions.

The data is more secured and the main advantage of Oracle 18c is automated tuning mechanism as well as it reduces the cost of maintenance operations and all maintenance is automated.

The main and primary feature of 18c is automation and reduce the human resource cost.Hope you get idea about new version of Oracle database.



Monday, December 26, 2016

ORA-01017:INVALID USERNAME/PASSWORD IN RMAN

I am trying to connect to target and auxiliary databases ,i got the below error

rman -0057
rman-00569
rman-00571
rman-00554: initialization of internal recovery manager failed
rman-04005:error from target database
ORA-01017:INVALID/USER PASSWORD LOGIN DENIED


To resolve this i tried changing sys user password so many times ,recreated password file and copied that to standby but nothing worked out.

Finally ,now  checking the following parameters

REMOTE_LOGIN_PASSWORD
REMOTE_OS_AUTHENT

By default the two above parameters should set to EXCLUSIVE and FALSE values respectively

But due to some reason,in my case set to NONE and TRUE,now i changed to EXCLUSIVE and FALSE then now its works fine

Wednesday, November 23, 2016

How to show user profile and change its limit ?

How to show user profile and change its limit ?


1. First see the profile which are using my user ;

      SELECT * FROM dba_users WHERE USERNAME='KMI';

2. For showing the specific profiles property

     select * from dba_profiles where profile='DEFAULT';

profile attribute
===================
    select * from DBA_PROFILES;


3.In order to track password related profile limits, Oracle stores the history of passwords for a user in user_history$.


select * from user_history$

select    username,   h.password,   password_date from    sys.user_history$ h,   dba_users where   user_id = user#;

4. To change profile limit use the following query

ALTER PROFILE default limit failed_login_attempts UNLIMITED;



CREATE USER kmi
    IDENTIFIED BY kmi
    DEFAULT TABLESPACE users
    TEMPORARY TABLESPACE temp_ts
    QUOTA unlimited ON users;






Listing All System Privilege Grants


The following query returns all system privilege grants made to roles and users:

SELECT * FROM DBA_SYS_PRIVS;

GRANTEE            PRIVILEGE                         ADM
--------------     --------------------------------- ---
SECURITY_ADMIN     ALTER PROFILE                     YES
SECURITY_ADMIN     ALTER USER                        YES
SECURITY_ADMIN     AUDIT ANY                         YES
SECURITY_ADMIN     AUDIT SYSTEM                      YES
SECURITY_ADMIN     BECOME USER                       YES
SECURITY_ADMIN     CREATE PROFILE                    YES
SECURITY_ADMIN     CREATE ROLE                       YES
SECURITY_ADMIN     CREATE USER                       YES
SECURITY_ADMIN     DROP ANY ROLE                     YES
SECURITY_ADMIN     DROP PROFILE                      YES
SECURITY_ADMIN     DROP USER                         YES
SECURITY_ADMIN     GRANT ANY ROLE                    YES
DBA                CREATE SESSION                    YES
DBA                ALTER SESSION                     YES
DBA                DROP TABLESPACE                   YES
DBA                BECOME USER                       YES
DBA                DROP ROLLBACK SEGMENT             YES
DBA                SELECT ANY TABLE                  YES
DBA                INSERT ANY TABLE                  YES
DBA                UPDATE ANY TABLE                  YES
DBA                DROP ANY INDEX                    YES
DBA                SELECT ANY SEQUENCE               YES
DBA                CREATE ROLE                       YES
DBA                EXECUTE ANY PROCEDURE             YES
DBA                ALTER PROFILE                     YES
DBA                CREATE ANY DIRECTORY              YES
DBA                CREATE ANY LIBRARY                YES
DBA                EXECUTE ANY LIBRARY               YES
DBA                ALTER ANY INDEXTYPE               YES
DBA                DROP ANY INDEXTYPE                YES
DBA                DEQUEUE ANY QUEUE                 YES
DBA                EXECUTE ANY EVALUATION CONTEXT    YES
DBA                EXPORT FULL DATABASE              YES
DBA                CREATE RULE                       YES
DBA                ALTER ANY SQL PROFILE             YES
DBA                ADMINISTER ANY SQL TUNING SET     YES
DBA                CHANGE NOTIFICATION               YES
DBA                DROP ANY EDITION                  YES
DBA                DROP ANY MINING MODEL             YES
DBA                ALTER ANY MINING MODEL            YES
DBA                ALTER ANY CUBE DIMENSION          YES
DBA                CREATE CUBE                       YES
DBA                DROP ANY CUBE BUILD PROCESS       YES
SYS                AUDIT SYSTEM                      NO
SYS                ALTER SESSION                     NO
SYS                ALTER ROLLBACK SEGMENT            NO
SYS                ALTER ANY CLUSTER                 NO
SYS                CREATE ANY INDEX                  NO
SYS                CREATE DATABASE LINK              NO
SYS                DROP PUBLIC DATABASE LINK         NO
SYS                GRANT ANY ROLE                    NO
SYS                ALTER ANY ROLE                    NO
SYS                EXECUTE ANY PROCED





Listing All Role Grants


The following query returns all the roles granted to users and other roles:

SELECT * FROM DBA_ROLE_PRIVS;

GRANTEE                        GRANTED_ROLE                   ADM DEF
------------------------------ ------------------------------ --- ---
SYS                            JMXSERVER                      YES YES
SYS                            XDB_SET_INVOKER                YES YES
SYS                            XDBADMIN                       YES YES
SYS                            IMP_FULL_DATABASE              YES YES
DBA                            SCHEDULER_ADMIN                YES YES
DBA                            DATAPUMP_IMP_FULL_DATABASE     NO  YES
SYSTEM                         AQ_ADMINISTRATOR_ROLE          YES YES
EXECUTE_CATALOG_ROLE           HS_ADMIN_EXECUTE_ROLE          NO  YES
HS_ADMIN_ROLE                  HS_ADMIN_EXECUTE_ROLE          NO  YES
OEM_MONITOR                    SELECT_CATALOG_ROLE            NO  YES
test                           CONNECT                        NO  YES
SYSMAN                         MGMT_USER                      YES YES






Listing Object Privileges Granted to a User


The following query returns all object privileges (not including column-specific privileges) granted to the specified user:

SELECT TABLE_NAME, PRIVILEGE, GRANTABLE FROM DBA_TAB_PRIVS     WHERE GRANTEE = 'TEST';

TABLE_NAME                     PRIVILEGE                                GRA
------------------------------ ---------------------------------------- ---
DAILY_EXPORTS                  WRITE                                    YES
DAILY_EXPORTS                  READ                                     YES
DAILY_EXPORTS                  EXECUTE                                  YES
ENCRYPT_TXT                    EXECUTE                                  NO
UTL_MAIL                       EXECUTE                                  NO
DECRYPT_TXT                    EXECUTE                                  NO



To list all the column-specific privileges that have been granted, use the following query:

SELECT GRANTEE, TABLE_NAME, COLUMN_NAME, PRIVILEGE     FROM DBA_COL_PRIVS;

GRANTEE      TABLE_NAME     COLUMN_NAME      PRIVILEGE
-----------  ------------   -------------    --------------
TEST         EMP            ENAME            INSERT
KMI          EMP            JOB              INSERT
TEST1        EMP            NAME             INSERT
TEST2        EMP            JOB              INSERT






Listing the Current Privilege Domain of Your Session


The following query lists all roles currently enabled for the issuer:

SELECT * FROM SESSION_ROLES;


If TEST has enabled the security_admin role and issues this query, then Oracle Database returns the following information:

ROLE
------------------------------
CONNECT
DBA
SELECT_CATALOG_ROLE
HS_ADMIN_SELECT_ROLE
EXECUTE_CATALOG_ROLE
HS_ADMIN_EXECUTE_ROLE
DELETE_CATALOG_ROLE
EXP_FULL_DATABASE
IMP_FULL_DATABASE
DATAPUMP_EXP_FULL_DATABASE
DATAPUMP_IMP_FULL_DATABASE
GATHER_SYSTEM_STATISTICS
SCHEDULER_ADMIN
XDBADMIN
XDB_SET_INVOKER
JAVA_ADMIN
JAVA_DEPLOY


The following query lists all system privileges currently available in the security domain of the issuer, both from explicit privilege grants and from enabled roles:

SELECT * FROM SESSION_PRIVS;


If swilliams has the security_admin role enabled and issues this query, then Oracle returns the following results:

PRIVILEGE
----------------------------------------
AUDIT SYSTEM
CREATE SESSION
CREATE USER
BECOME USER
ALTER USER
DROP USER
CREATE ROLE
DROP ANY ROLE
GRANT ANY ROLE
AUDIT ANY
CREATE PROFILE
ALTER PROFILE
DROP PROFILE


If the security_admin role is disabled for TEST, then the first query would return no rows, while the second query would only return a row for the CREATE SESSION privilege grant.





Listing Roles of the Database


The DBA_ROLES data dictionary view can be used to list all roles of a database and the authentication used for each role. For example, the following query lists all the roles in the database:

SELECT * FROM DBA_ROLES;

ROLE                  PASSWORD
----------------      --------
CONNECT               NO
RESOURCE              NO
DBA                   NO
SECURITY_ADMIN        YES






Listing Information About the Privilege Domains of Roles


The ROLE_ROLE_PRIVS,ROLE_SYS_PRIVS, and ROLE_TAB_PRIVS data dictionary views contain information on the privilege domains of roles. For example, the following query lists all the roles granted to the system_admin role:

SELECT GRANTED_ROLE, ADMIN_OPTION   FROM ROLE_ROLE_PRIVS   WHERE ROLE = 'DBA';

GRANTED_ROLE                   ADM
------------------------------ ---
SCHEDULER_ADMIN                YES
DATAPUMP_IMP_FULL_DATABASE     NO
DELETE_CATALOG_ROLE            YES
EXECUTE_CATALOG_ROLE           YES
EXP_FULL_DATABASE              NO
SELECT_CATALOG_ROLE            YES
JAVA_DEPLOY                    NO
GATHER_SYSTEM_STATISTICS       NO
JAVA_ADMIN                     NO
XDB_SET_INVOKER                NO
DATAPUMP_EXP_FULL_DATABASE     NO
XDBADMIN                       NO
IMP_FULL_DATABASE              NO


The following query lists all the system privileges granted to the security_admin role:

SELECT * FROM ROLE_SYS_PRIVS WHERE ROLE = 'DBA';

ROLE                           PRIVILEGE                                ADM
------------------------------ ---------------------------------------- ---
DBA                            CREATE SESSION                           YES
DBA                            ALTER SESSION                            YES
DBA                            DROP TABLESPACE                          YES
DBA                            BECOME USER                              YES
DBA                            DROP ROLLBACK SEGMENT                    YES
DBA                            SELECT ANY TABLE                         YES
DBA                            INSERT ANY TABLE                         YES
DBA                            UPDATE ANY TABLE                         YES
DBA                            DROP ANY INDEX                           YES
DBA                            SELECT ANY SEQUENCE                      YES
DBA                            CREATE ROLE                              YES
DBA                            EXECUTE ANY PROCEDURE                    YES
DBA                            ALTER PROFILE                            YES
DBA                            CREATE ANY DIRECTORY                     YES
DBA                            CREATE ANY LIBRARY                       YES
DBA                            EXECUTE ANY LIBRARY                      YES


The following query lists all the object privileges granted to the security_admin role:

SELECT TABLE_NAME, PRIVILEGE FROM ROLE_TAB_PRIVS    WHERE ROLE = 'DBA';

TABLE_NAME                     PRIVILEGE
------------------------------ ----------------------------------------
MAP_OBJECT                     INSERT
DBMS_LOGSTDBY                  EXECUTE
V_$DIAG_PROBLEM                SELECT
V_$DIAG_HM_FINDING             SELECT
V_$DIAG_IPS_CONFIGURATION      SELECT
V_$DIAG_INC_METER_IMPT_DEF     SELECT
V_$DIAG_AMS_XACTION            SELECT
V_$DIAG_VPROBLEM_INT           SELECT
V_$DIAG_VPROBLEM1              SELECT
V_$DIAG_VPROBLEM_BUCKET_COUNT  SELECT
V_$DIAG_VNOT_EXIST_INCIDENT    SELECT
DBMS_RESUMABLE                 EXECUTE
DBMS_SERVER_ALERT              EXECUTE
DBMS_HM                        EXECUTE
DBMS_WORKLOAD_REPLAY           EXECUTE
DBMS_DEFER_SYS                 EXECUTE
AW$                            SELECT
AW_TRACK$                      SELECT
XDB$H_LINK                     DELETE
XDB$H_LINK                     SELECT
XDB$H_LINK                     UPDATE
XDB$H_LINK                     QUERY REWRITE