Saturday 14 September 2013

  How to create Oracle password verify function.

How To Create Oracle Password Verify Function. 

1. create password_verify function by sys

CREATE OR REPLACE FUNCTION toa_pass_verify (
   username       VARCHAR2,
   PASSWORD       VARCHAR2,
   old_password   VARCHAR2
)
   RETURN BOOLEAN
IS
   n                BOOLEAN;
   m                INTEGER;
   differ           INTEGER;
   isdigit          BOOLEAN;
   ischarlower      BOOLEAN;
   ischarupper      BOOLEAN;
   ispunct          BOOLEAN;
   digitarray       VARCHAR2 (20);
   punctarray       VARCHAR2 (25);
   chararraylower   VARCHAR2 (52);
   chararrayupper   VARCHAR2 (52);
BEGIN
   digitarray := '0123456789';
   chararraylower := 'abcdefghijklmnopqrstuvwxyz';
   chararrayupper := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
   punctarray := '!"#$%&()``*+,-/:;<=>?_{}[]';

-- Check if the password is same as the username
   IF NLS_LOWER (PASSWORD) = NLS_LOWER (username)
   THEN
      raise_application_error (-20001, 'Password same as or similar to user');
   END IF;

-- Check for the minimum length of the password
   IF LENGTH (PASSWORD) < 8
   THEN
      raise_application_error (-20002, 'Password length less than 8');
   END IF;

-- Check if the password is too simple. A dictionary of words may be
-- maintained and a check may be made so as not to allow the words
-- that are too simple for the password.
   IF NLS_LOWER (PASSWORD) IN
         ('welcome', 'database', 'account', 'user', 'password', 'oracle',
          'computer', 'abcd')
   THEN
      raise_application_error (-20002, 'Password too simple');
   END IF;

-- Check if the password contains at least one letter, one digit and one
-- punctuation mark.
-- 1. Check for the digit
   isdigit := FALSE;
   m := LENGTH (PASSWORD);

   FOR i IN 1 .. 10
   LOOP
      FOR j IN 1 .. m
      LOOP
         IF SUBSTR (PASSWORD, j, 1) = SUBSTR (digitarray, i, 1)
         THEN
            isdigit := TRUE;
            --GOTO findcharlower;
         END IF;
      END LOOP;
   END LOOP;

   IF isdigit = FALSE
   THEN
      raise_application_error
         (-20003,
          'Password should contain at least one digit'
         );
   END IF;

-- 2. Check for the lowwer case character
   ischarlower := FALSE;

   FOR i IN 1 .. LENGTH (chararraylower)
   LOOP
      FOR j IN 1 .. m
      LOOP
         IF SUBSTR (PASSWORD, j, 1) = SUBSTR (chararraylower, i, 1)
         THEN
            ischarlower := TRUE;
            --GOTO findcharupper;
         END IF;
      END LOOP;
   END LOOP;

   IF ischarlower = FALSE
   THEN
      raise_application_error
         (-20003,
          'Password should contain at least one lower case character and one punctuation'
         );
   END IF;

-- 3. Check for the upper case character
   ischarupper := FALSE;

   FOR i IN 1 .. LENGTH (chararrayupper)
   LOOP
      FOR j IN 1 .. m
      LOOP
         IF SUBSTR (PASSWORD, j, 1) = SUBSTR (chararrayupper, i, 1)
         THEN
            ischarupper := TRUE;
            --GOTO findpunct;
         END IF;
      END LOOP;
   END LOOP;

   IF ischarupper = FALSE
   THEN
      raise_application_error
         (-20003,
          'Password should contain at least one upper character and one punctuation'
         );
   END IF;

-- 4. Check for the punctuation
   ispunct := FALSE;

   FOR i IN 1 .. LENGTH (punctarray)
   LOOP
      FOR j IN 1 .. m
      LOOP
         IF SUBSTR (PASSWORD, j, 1) = SUBSTR (punctarray, i, 1)
         THEN
            ispunct := TRUE;
            --GOTO endsearch;
         END IF;
      END LOOP;
   END LOOP;

   IF ispunct = FALSE
   THEN
      raise_application_error
         (-20003,
          'Password should contain at least one digit, one character and one punctuation'
         );
   END IF;

-- Everything is fine; return TRUE ;
   RETURN (TRUE);
END;
/


2. create profile:

CREATE PROFILE MY_PROFILE LIMIT
  FAILED_LOGIN_ATTEMPTS 3  -- Account locked after 3 failed logins.
  PASSWORD_LOCK_TIME unlimited     -- Number of days account is locked for. UNLIMITED required explicit unlock by DBA.
  PASSWORD_LIFE_TIME 60    -- Password expires after 90 days.
  PASSWORD_GRACE_TIME 6    -- Grace period for password expiration.
  PASSWORD_REUSE_TIME 360  -- Number of days until a specific password can be reused. UNLIMITED means never.
  PASSWORD_REUSE_MAX 6    -- The number of changes required before a password can be reused. UNLIMITED means never.
  PASSWORD_VERIFY_FUNCTION PASSWORD_VERIFY

  3. create users:

create user          TEST
identified by        password4TEST#
profile              MY_PROFILE

Wednesday 11 September 2013

Valuable For DBA.

Oracle DBA Responsibilities

(1) Creates and maintains all databases required for development, testing, 
education and production usage.

(2) Performs the capacity planning required to create and maintain the 
databases. The DBA works closely with system administration staff because 
computers often have applications or tools on them in addition to the Oracle 
Databases.

(3) Performs ongoing tuning of the database instances.

(4) Install new versions of the Oracle RDBMS and its tools and any other tools
that access the Oracle database. 

(5) Plans and implements backup and recovery of the Oracle database.

(6) Controls migrations of programs, database changes, reference data changes 
and menu changes through the development life cycle.

(7) Implements and enforces security for all of the Oracle Databases. 

(8) Performs database re-organisations as required to assist performance and 
ensure maximum uptime of the database.

(9) Puts standards in place to ensure that all application design and code is 
produced with proper integrity, security and performance. The DBA will perform
reviews on the design and code frequently to ensure the site standards are 
being adhered to.

(10) Evaluates releases of Oracle and its tools, and third party products to 
ensure that the site is running the products that are most appropriate. 
Planning is also performed by the DBA, along with the application developers 
and System administrators, to ensure that any new product usage or release 
upgrade takes place with minimal impact.

(11) Provides technical support to application development teams. This is 
usually in the form of a help desk. The DBA is usually the point of contact 
for Oracle Corporation. 

(12) Enforces and maintains database contraints to ensure integrity of the 
database.

(13) Administers all database objects, including tables, clusters, indexes, 
views, sequences, packages and procedures. 

(14) Assists with impact analysis of any changes made to the database objects.

(15) Troubleshoots with  problems regarding the databases, applications and 
development tools.

(16) Create new database users as required.

(17) Manage sharing of resources amongst applications.

(18) The DBA has ultimate responsibility for the physical database design. 

 

The DBA should posses the following skills

(1) A good knowledge of the operating system(s)

(2) A good knowledge of physical database design

(3) Ability to perform both Oracle and also operating system performance 
monitoring and the necessary adjustments.

(4) Be able to provide a strategic database direction for the organisation.

(5) Excellent knowledge of Oracle backup and recovery scenarios.

(6) Good skills in all Oracle tools.

(7) A good knowledge of Oracle security management.

(8) A good knowledge of how Oracle acquires and manages resources.

(9) Sound knowledge of the applications at your site.

(10) Experience and knowledge in migrating code, database changes, data and 
menus through the various stages of the development life cycle.

(11) A good knowledge of the way Oracle enforces data integrity.

(12) A sound knowledge of both database and program code performance tuning.

(13) A DBA should possess a sound understanding of the business.

(14) A DBA should have sound communication skills with management, development
teams, vendors, systems administrators and other related service providers.

Shahab_Patels (Views for Database Administrators): Wellcome To The World of DBAs!!!!!!!!!!!!

Shahab_Patels (Views for Database Administrators): Wellcome To The World of DBAs!!!!!!!!!!!!