Thursday, August 5, 2010

Applying Db2 licenses on DB2 Database once existing license expired

Often we come into situation where the existing db2 license got expired and we cannot able to start the instance and running into below error

bash-3.2$ db2start
08/05/2010 23:31:34 0 0 SQL8000N DB2START processing failed; a valid product license was not found. If you have licensed this product, ensure the license key is properly registered. You can register the license via the License Center or db2licm command line utility. The license key can be obtained from your licensed product CD.
SQL1032N No start database manager command was issued. SQLSTATE=57019


To resolve the above error, you can see when the expired date for license with below command

bash-3.2$ db2licm -l
Product name: "DB2 Enterprise Server Edition"
Expiry date: "Expired"
Product identifier: "db2ese"
Version information: "9.5"

Product name: "DB2 Connect Server"
Expiry date: "Expired"
Product identifier: "db2consv"
Version information: "9.5"
Concurrent connect user policy: "Disabled"
Enforcement policy: "Soft Stop"


You have to remove the license and apply the license to start the db2 instance. Below are the swiches you can use with db2licm

======
db2licm [-a filename]
[-e product-identifier HARD | SOFT]
[-p product-identifier
CONCURRENT | OFF]
[-r product-identifier]
[-u product-identifier num-users]
[-c product-identifier num-connectors]
[-g filename]
[-x]
[-l][show detail]
[-v]
[-?]

The command options are:

-a Adds a license for a product. Specify a file name containing
valid license information. This can be obtained from your
licensed product CD or contact your IBM representative or
authorized dealer.

-e Updates the enforcement policy on the system. Valid values are:
HARD and SOFT. HARD specifies that unlicensed requests will not
be allowed. SOFT specifies that unlicensed requests will be
logged but not restricted.

-p Updates the license policy type to use on the system. The
keyword CONCURRENT can be specified for concurrent user policy.
Specify OFF to turn off all policies.

-r Removes the license for a product. Specify the product
identifier.

-u Updates the number of user entitlements that have been
purchased. Specify the product identifier and the number of
users.

-c Updates the number of connector entitlements that have been
purchased. Specify the product identifier and the number of
connector entitlements.

-g Generates compliance report. Specify file name where output is
to be stored.

-x Resets license compliance information for the purposes of
license compliance report.

-l[show detail]
Lists all the products with available license information,
including the product identifier. Specify [show detail] to view
detailed information about licensed features (if any).

-v Displays version information.

-? Displays help information. When this option is specified, all
other options are ignored, and only the help information is
displayed.

=====

To remove db2 license


bash-3.2$ db2licm -r "db2ese"

LIC1403I License removed successfully.


=====

To apply db2 license

bash-3.2$ db2licm -a "/data1/db2/databases/v95inst1/db2ese.lic"

LIC1448I This license was automatically applied at install time in
order to enable you to start working with DB2

Tuesday, August 3, 2010

Finding out Oracle Execution plan plus how much time the query take to complete

SQL> conn system/admin as sysdba
Connected.
SQL> SET AUTOTRACE ON
SQL> select * from scott.emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30


EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- --------- ---------- --------- ---------- ---------- ----------
7566 JONES MANAGER 7839 02-APR-81 2975 20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30

7698 BLAKE MANAGER 7839 01-MAY-81 2850 30


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10


14 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 3956160932

--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 518 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| EMP | 14 | 518 | 3 (0)| 00:00:01 |--------------------------------------------------------------------------


Statistics
----------------------------------------------------------
340 recursive calls
0 db block gets
69 consistent gets
0 physical reads
0 redo size
1415 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
5 sorts (memory)
0 sorts (disk)
14 rows processed


==============

To get how much time the query takes to complete, one can follow the below approach

SQL> spool timing.log
SQL> select * from scott.emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10


14 rows selected.

SQL> cle scr
SQL> spool display.log
SQL> SET TIMING ON
SQL> select * from scott.emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30


EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10


14 rows selected.

Elapsed: 00:00:00.00
SQL> spool off