Search This Blog

Showing posts with label New Thing What I learn EVERY DAY. Show all posts
Showing posts with label New Thing What I learn EVERY DAY. Show all posts

Saturday, September 10, 2011

Oracle Logical Database Limits from 7 to 11gr2 --- worth to know...

Between Oracle 7 to 8 "column" item upgraded.

Column Limits in Oracle 7
columns
LONG columns
index (or cluster index) table expression list view definition16 columns maximum 254 columns maximum 254 columns maximum 254 columns maximum
table1 LONG column per table
Oracle 8 --- Logical Database Limit
item Type Limit 
GROUP BY clause 
Maximum length 
The GROUP BY expression and all of the nondistinct aggregates functions (e.g., SUMAVG) must fit within a single database block. 
Indexes 
Maximum per table 
Unlimited 
total size of indexed column 
40% of the database block size minus some overhead. 
Columns 
Per table 
1000 columns maximum 
Per index (or clustered index) 
32 columns maximum 

Per bitmapped index 
30 columns maximum 
Constraints 
Maximum per column 
Unlimited 
Nested Queries 
Maximum number 
255  
Partitions 
Maximum length of linear partitioning key 
4KB - overhead 
Maximum number of columns in partition key 
16 columns 
Maximum number of partitions allowed per table or index 
64K-1 partitions 
Rollback Segments 
Maximum number per database 
No limit; limited within a session by the MAX_ROLLBACK_SEGMENTS initialization parameter 
Rows 
Maximum number per table 
Unlimited 
SQL Statement Length 
Maximum length of statements 
64K maximum; particular tools may impose lower limits. 
Stored Packages 
Maximum size 
PL/SQL and Developer/2000 may have limits on the size of stored procedures they can call. The limits typically range from 2000 to 3000 lines of code.
See Also: Your PL/SQL or Developer/2000 documentation for details.  
Trigger Cascade Limit 
Maximum value 
Operating system dependent, typically 32. 
Users and Roles 
Maximum 
2,147,483,638 
Tables 
Maximum per clustered table 
32 tables 
Maximum per database 
Unlimite

Oracle 9ir1 --- Logical Database Limit
In this release the below new items are introduced Or improved.
subqueries 
Maximum levels of subqueries in a SQL statement 
Unlimited in the FROM clause of the top-level query
255 subqueries in the WHERE clause 




Oracle 10gr2 --- Logical Database Limit
In this release the below new items are introduced Or improved.
CREATE MATERIALIZED VIEW definitionMaximum size64K Bytes


Note:
The limit on how long a SQL statement can be depends on many factors, including database configuration, disk space, and memory
Note:
When an object instance exists in memory, there is no fixed limit on the number of attributes in the object. But the maximum total amount of memory consumed by an object instance is 4 GB.When an object instance is inserted into a table, the attributes are exploded into separate columns in the table, and the Oracle 1000-column limit applies.



Oracle 11gr1 --- Logical Database Limit
NO changes between 10gr2 to 11gr1

Oracle 11gr2 --- Logical Database Limit
NO changes between 11gr1 to 11gr2

NOTE: Please refer oracle official documentation for more information : http://tahiti.oracle.com



Saturday, September 3, 2011

How to find the dependencies of table

Today i come across one OTN thread and learn about dbms_utility. dependency plsql package.
with this package we can check the objects dependency on another objects.

 SQL} create table TEST
  2  (col varchar2(10));


Table created.




SQL} create or replace procedure PR_TEST is
  2  i number;
  3  begin
  4  select count(*) into i from test;
  5  dbms_output.put_line(to_char(i));
  6  end;
  7  /


Procedure created.


SQL} set serveroutput on




SQL} exec dbms_utility.get_dependency('TABLE','TAJ','TEST');
-
DEPENDENCIES ON TAJ.TEST
------------------------------------------------------------------
*TABLE TAJ.TEST()
*   PROCEDURE TAJ.PR_TEST()


PL/SQL procedure successfully completed.


There are other subprogram are listed below of dbms_utility plsql package.



Table 141-3 DBMS_UTILITY Package Subprograms
SubprogramDescription
ACTIVE_INSTANCES ProcedureReturns the active instance
ANALYZE_DATABASE ProcedureAnalyzes all the tables, clusters and indexes in a database
ANALYZE_PART_OBJECT ProcedureAnalyzes the given tables and indexes
ANALYZE_SCHEMA ProcedureAnalyzes all the tables, clusters and indexes in a schema
CANONICALIZE ProcedureCanonicalizes a given string
COMMA_TO_TABLE ProceduresConverts a comma-delimited list of names into a PL/SQL table of names
COMPILE_SCHEMA ProcedureCompiles all procedures, functions, packages, views and triggers in the specified schema
CREATE_ALTER_TYPE_ERROR_TABLE ProcedureCreates an error table to be used in the EXCEPTION clause of the ALTER TYPE statement
CURRENT_INSTANCE FunctionReturns the current connected instance number
DATA_BLOCK_ADDRESS_BLOCK FunctionGets the block number part of a data block address
DATA_BLOCK_ADDRESS_FILE FunctionGets the file number part of a data block address
DB_VERSION ProcedureReturns version information for the database
EXEC_DDL_STATEMENT ProcedureExecutes the DDL statement in parse_string
FORMAT_CALL_STACK FunctionFormats the current call stack
FORMAT_ERROR_BACKTRACE FunctionFormats the backtrace from the point of the current error to the exception handler where the error has been caught
FORMAT_ERROR_STACK FunctionFormats the current error stack
GET_CPU_TIME FunctionReturns the current CPU time in 100th's of a second
GET_DEPENDENCY ProcedureShows the dependencies on the object passed in.
GET_HASH_VALUE FunctionComputes a hash value for the given string
GET_PARAMETER_VALUE FunctionGets the value of specified init.ora parameter
GET_TIME FunctionFinds out the current time in 100th's of a second
INVALIDATE ProcedureInvalidates a database object and (optionally) modifies its PL/SQL compiler parameter settings
IS_CLUSTER_DATABASE FunctionFinds out if this database is running in cluster database mode
MAKE_DATA_BLOCK_ADDRESS FunctionCreates a data block address given a file number and a block number
NAME_RESOLVE ProcedureResolves the given name
NAME_TOKENIZE ProcedureCalls the parser to parse the given name
OLD_CURRENT_SCHEMA FunctionReturns the session value that was returned by SYS_CONTEXT ('USERENV', 'CURRENT_SCHEMA')
OLD_CURRENT_USER FunctionReturns the session value that was returned by SYS_CONTEXT ('USERENV', 'CURRENT_USER')
PORT_STRING FunctionReturns a string that uniquely identifies the version of Oracle and the operating system
SQLID_TO_SQLHASH FunctionConverts a SQL ID into a hash value
TABLE_TO_COMMA ProceduresConverts a PL/SQL table of names into a comma-delimited list of names
VALIDATE ProcedureMakes invalid database objects valid



find more info : dbms_utility



Thursday, August 25, 2011

Restore database without backup with original database files

Today i come across one of the OTN forums question regarding "How to restore database without backup with original database files"

As mentioned in the question is:
OS windows
Oracle Ver: 10.1.0.5.0

by mistake user deleted the registry and uninstall the oracle software from OS. but he took the backup of original database files (redo.control.datafile)

the database was up and running while he deleted all registry and uninstall oracle software via Oracle Universal Installer.

Not in the particular case but also we can re-build database if we have intact original database files.

the following steps will be helpful
1.  Install Oracle software 
2. Install any patchset or cpu ( same as before uninstalled)
3. create oracle services via ORADIM ( SID should be same as original database SID)
4. create password files
5. create pfile ( with the required parameters) You can create one dummy database and take the pfile from that database for reference.
6. create the needful directories ( like oradata/admin/bdump/udump/cdump) etc
7. restore original database files from backup to oradata folder 
NOTE: It is better if file structure should be same as before uninstall otherwise we need to change the location of controlfiles then relocate redolog and datafiles to the new locations
8. connect to the idle instance with created pfile 
9. start database in steps ( to that we can verify and change locations of the files (if required)
10. startup nomount
11. alter database mount
12. alter database open

if you can open successful then write me email at askdbataj

Wednesday, August 17, 2011

Oracle Stream Setup in 11GR2

Dear All,
Oracle Streams configuration with 11gr2

OS: Windows 2003
Oracle: 11GR2

Source Database: DB01
Target Database: DB02
SCHEMAS used in stream: scott
Type of replication environment : bi - directional replication in a two database replication 
environment

Step:
Note: 
1. Enable archivelog mode on source/target database
2. unlock scott schema (by default it is locked)

1. configure an oracle streams administrator on all databases
1.1 create tablespace (optional)
1.2 create user
1.3 grant privileges

2. configure network connectivity and database links
2.1 edit TNSNAMES.ORA file for target and source database
2.2 create database links on both databases ( source/ target)

3. setting init parameter relevant to oracle streams
3.1 set global_names= true parameter

4. specifying supplemental logging
4.1 add supplemental log on all tables

5. configure two-database schema replication with local capture
This example configures an oracle streams replication environment that replicates DML changes to 

all of the tables in the scott schema. this example configures a two-database replications 
environment with local captuer processes to capture changes.

5.1 creating the required directory objects
5.2 connect to db01 and run MAINTAIN_SCHEMAS procedure

6. configure latest time conflict resolution (cover in next post )

C:\>rem enable archive log mode on target/source db

C:\>set oracle_sid=db01

C:\>sqlplus sys/oracle as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Mon Aug 15 13:07:29 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  535662592 bytes
Fixed Size                  1384752 bytes
Variable Size             348131024 bytes
Database Buffers          180355072 bytes
Redo Buffers                5791744 bytes
Database mounted.
SQL> alter database archivelog ;

Database altered.

SQL> alter database open;

Database altered.

SQL> --unlock scott schema
SQL> alter user scott account unlock;

User altered.

SQL> conn scott/tiger
ERROR:
ORA-28001: the password has expired


Changing password for scott
New password:
Retype new password:
Password changed
Connected.
SQL>

################## repeat the above steps on DB02 ###################

SQL> conn sys/oracle@db01 as sysdba
Connected.
SQL> --create new tablespace
SQL> create tablespace STREAM
  2  datafile 'c:\stream01.dbf' size 25m
  3  autoextend on;

Tablespace created.

SQL> --create user for stream
SQL> create user STRMADMIN
  2  identified by strmadmin;

User created.

SQL> --grant previleges to stream administrator user
SQL> grant DBA to strmadmin;

Grant succeeded.

SQL> begin
  2  dbms_streams_auth.grant_admin_privilege (
  3  grantee =>'strmadmin',
  4  grant_privileges => TRUE);
  5  end;
  6  /

PL/SQL procedure successfully completed.

################## repeat the above same step on DB02 ###################


db02 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.104.23)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = db02)
    )
  )

db01 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.104.23)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = db01)
    )
  )

Add above lines to TNSNAMES.ORA file ( replace the HOST and SERIVCE_NAME as per your 
environment)
########################################################################

SQL> --create db link on target db i.e. DB01
SQL> conn strmadmin/strmadmin@db01
Connected.
SQL> create database link db02
  2  connect to strmadmin
  3  identified by strmadmin
  4  using 'db02';

Database link created.



SQL> --create db link on target db i.e. DB02
SQL> conn  strmadmin/strmadmine@db02 
Connected.
SQL> create database link db01
  2  connect to strmadmin
  3  identified by strmadmin
  4  using 'db01';

Database link created.

########################################################################
SQL> conn strmadmin/strmadmin@db01
Connected.
SQL> --setup init parameter
SQL> alter system set global_names=true;

System altered.

SQL> conn strmadmin/strmadmin@db02
Connected.
SQL> alter system set global_names=true;

System altered.

#######################################################################

SQL> conn strmadmin/strmadmin@db01
Connected.
SQL> --specifying supplemental logging
SQL> --scott schema has FOUR table i.e. emp/dept/bouns/salgrade
SQL> alter table scott.emp add supplemental log data (all) columns;

Table altered.

SQL> alter table scott.dept add supplemental log data (all) columns;

Table altered.


SQL> alter table scott.bonus add supplemental log data (all) columns;

Table altered.

SQL> alter table scott.salgrade add supplemental log data (all) columns;

Table altered.

################## repeat the above same step on DB02 ###################
SQL> conn strmadmin/strmadmin@db01
Connected.
SQL> create directory dir_db01 as 'c:\tmp\db01';

Directory created.


SQL> --create destination direcotory on db02(target db)
SQL> conn strmadmin/strmadmin@db02
connected.

SQL> create directory dir_db02 as 'c:\tmp\db02';

Directory created.

################## ############################# ###################
connect with stream administrator and run maintain_schemas procedure on source db (db01)

SQL> --create to the source database (db01) with stream administrator user
SQL> --execute the following procedure
SQL> conn strmadmin/strmadmin@db01
Connected.
SQL> BEGIN
  2    DBMS_STREAMS_ADM.MAINTAIN_SCHEMAS(
  3      schema_names                 => 'scott',
  4      source_directory_object      => 'dir_db01',
  5      destination_directory_object => 'dir_db02',
  6      source_database              => 'db01',
  7      destination_database         => 'db02',
  8      include_ddl                     => TRUE,
  9      instantiation           => DBMS_STREAMS_ADM.INSTANTIATION_SCHEMA,
 10      bi_directional               => TRUE); -- Set to TRUE for bi-directiona
l
 11  END;
 12  /

PL/SQL procedure successfully completed.

################## ############################# ###################
let check the stream is configured properly or not.
add new employee in the scott.emp at db01 database;
SQL> conn scott/tiger@db01
Connected.
SQL> select count(*) from emp;

  COUNT(*)
----------
        14

SQL> --let add new employee on source db (db01)
SQL> insert into emp
  2  values (007,'TEST','testing',10,sysdate,100,0,20);

1 row created.

SQL> --let check on target db (db02)
SQL> conn scott/tiger@db02
Connected.
SQL> select empno,ename,job,mgr,hiredate from emp where empno=007;

     EMPNO ENAME      JOB              MGR HIREDATE
---------- ---------- --------- ---------- ---------
         7 TEST       testing           10 17-AUG-11

SQL> --DML operation are working perfectly.
SQL> --let check DDL operations
SQL> --add new column in the emp table in target db (db02)
SQL> alter table emp
  2  add (ID NUMBER DEFAULT 0);

Table altered.

SQL> --check on source db (db01)
SQL> conn scott/tiger@db01
Connected.
SQL> desc emp
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------

 EMPNO                                     NOT NULL NUMBER(4)
 ENAME                                              VARCHAR2(10)
 JOB                                                VARCHAR2(9)
 MGR                                                NUMBER(4)
 HIREDATE                                           DATE
 SAL                                                NUMBER(7,2)
 COMM                                               NUMBER(7,2)
 DEPTNO                                             NUMBER(2)
 ID                                                 NUMBER

SQL> --DDL operation are also working :)
SQL> --and this is vice versa stream configuration.

Important considerations for the configuration procedures

1. Local or downstream capture for the source database
The database on which the procedure is run is configured as the capture database for changes made to the source database. Therefore, to configure local capture at the source database, run the procedure at the source database. 
procedure : dbms_streams_adm.maintain_schemas

2. Perform configuration actions directly or with a script
To configure an Oracle Streams replication environment directly when you run one of these procedures, set the perform_actions parameter to TRUE. The default value for this parameter is TRUE.

Direct option configure stream environment immediately.

3. Oracle Streams Components configured by these procedures
The capture_name and capture_queue_name parameters must be set to NULL when both of the following conditions are met:

The destination database is the capture database.
The bi_directional parameter is set to TRUE.

4. One-way or Bi-Directional replication
If you set the bi_directional parameter to TRUE when you run one of these procedures, then do not allow data manipulation language (DML) or data definition language (DDL) changes to the shared database objects at the destination database while the procedure, or the script generated by the procedure, is running. This restriction does not apply if a procedure is configuring a single-source replication environment.

5. DDL changes
To configure an Oracle Streams replication environment that does not maintain DDL changes, set the include_ddl parameter to FALSE when you run one of these procedures. The default value for this parameter is FALSE.
Set include_DDL = TRUE (in this example)

6. Instantiaion
To specify this instantiation option, set the instantiation parameter to  the following values:
DBMS_STREAMS_ADM.INSTANTIATION_SCHEMA if you run the MAINTAIN_SCHEMAS procedure

write me email in case of any queries at askdbataj

Tuesday, August 2, 2011

How to find User Has what privileges and roles in Oracle Database

Simple way to find out "User Has what privileges and roles"
Query 
session_privs
session_roles

NOTE: above view only help to connected database user.

But All others user query
DBA_AQ_AGENT_PRIVS 
DBA_COL_PRIVS 
DBA_COL_PRIVS_MADE 
DBA_COL_PRIVS_RECD 
DBA_REPGROUP_PRIVILEGES 
DBA_ROLE_PRIVS 
DBA_RSRC_CONSUMER_GROUP_PRIVS 
DBA_RSRC_MANAGER_SYSTEM_PRIVS 
DBA_SYS_PRIVS 
DBA_TAB_PRIVS 
DBA_TAB_PRIVS_MADE 
DBA_TAB_PRIVS_RECD 
DBA_NETWORK_ACL_PRIVILEGES 
_DBA_STREAMS_PRIVILEGED_DBA 
DBA_WM_PRIVS 
DBA_WORKSPACE_PRIVS 
DBA_EXPFIL_PRIVILEGES 
DBA_RLMGR_PRIVILEGES

for the readymade scripts visit @ Scripts

Sunday, July 24, 2011

Oracle Login Failed Message

In oracle application r12 LOGIN PAGE
when we enter wrong password then we get below message.

Error
Login failed. Please verify your login information or contact the system administrator.

And suppose if we set ""Signon Password Failure Limit "" = 2 , mean after two failed attempt account get locks. but the difficulty with the message.
In the First attempt with wrong password we get above mentioned error msg.
In the Second attempt with wrong password same msg as above
But in the 3rd attempt it should show and say "Account Locked" Or something like.

but that functionality at the moment is not available in the oracle application.

even though we can edit the current display message with the following SQL statement.
SQL> select *
from fnd_new_messages
where message_name = 'FND_APPL_LOGIN_FAILED';

Related Info:
How To Add An Informational Tip Icon Next To An Item On A Framework Page? [ID 973389.1]

Sunday, January 24, 2010

Java could not be located. OPatch cannot proceed

Hi,

After a very long time i am going to post ... :) , the reason is didn't get time for posting. sorry for that.

Critical Patch Update (CPU) January-2010 released.

I was applying CPU to all our PRODUCTION box.

one of my DEV box (win2k3 + 11gr1) i was getting below error message.

"Java could not be located. OPatch cannot proceed ..."

Java.exe exist in the $JAVA_HOME folder & $JAVA_HOME properly set , but still getting the same message.

There is a small workaround to use "-jdk" and full path of JAVA.EXE.

something like below

%ORACLE_HOME%OPatch>opatch apply -jdk <<{full path of JAVA.EXE}>>

with the "-jdk" parameter opatch will find the JAVA.EXE and executed without error.

Thanks