step to change DBID using NID command
[oracle@oracle@example dupli]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 4 16:13:26 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: /as sysdba
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 293603712 bytes
Database Buffers 121634816 bytes
Redo Buffers 6094848 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@oracle@example dupli]$ nid target=/
DBNEWID: Release 11.2.0.1.0 - Production on Thu Jul 4 16:13:51 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to database DB11G (DBID=289552766)
Connected to server version 11.2.0
Control Files in database:
/u01/app/oracle/oradata/db11g/control01.ctl
/u01/app/oracle/oradata/db11g/control02.ctl
Change database ID of database DB11G? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 289552766 to 289542527
Control File /u01/app/oracle/oradata/db11g/control01.ctl - modified
Control File /u01/app/oracle/oradata/db11g/control02.ctl - modified
Datafile /u01/app/oracle/oradata/db11g/system01.db - dbid changed
Datafile /u01/app/oracle/oradata/db11g/sysaux01.db - dbid changed
Datafile /u01/app/oracle/oradata/db11g/undotbs01.db - dbid changed
Datafile /u01/app/oracle/oradata/db11g/users01.db - dbid changed
Datafile /u01/app/oracle/oradata/db11g/temp01.db - dbid changed
Control File /u01/app/oracle/oradata/db11g/control01.ctl - dbid changed
Control File /u01/app/oracle/oradata/db11g/control02.ctl - dbid changed
Instance shut down
Database ID for database DB11G changed to 289542527.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.
[oracle@oracle@example dupli]$
[oracle@oracle@example dupli]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 4 16:20:36 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: /as sysdba
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 293603712 bytes
Database Buffers 121634816 bytes
Redo Buffers 6094848 bytes
Database mounted.
SQL> alter database open resetlogs;
Database altered.
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
DB11G READ WRITE
***********END*****************
Thursday, 4 July 2013
how to start Auditing in oracle Database?
As per organization policy we should set Auditing on particular user,oracle database objects etc.
we set this auditing policy to check if any unwanted operation has been performed on production database.
so my this post shows you how to start auditing on purticular table and user operation.
SQL> SHOW PARAMETER AUDIT
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/db11g/ad
ump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string DB
AUDIT_TRAIL = { none | os | db | db,extended | xml | xml,extended }
The following list provides a description of each setting:
none or false - Auditing is disabled.
db or true - Auditing is enabled, with all audit records stored in the database audit trial (SYS.AUD$).
db,extended - As db, but the SQL_BIND and SQL_TEXT columns are also populated.
xml- Auditing is enabled, with all audit records stored as XML format OS files.
xml,extended - As xml, but the SQL_BIND and SQL_TEXT columns are also populated.
os- Auditing is enabled, with all audit records directed to the operating system's audit trail.
SQL> ALTER SYSTEM SET audit_trail=db SCOPE=SPFILE;
System altered.
SQL> SHUTDOWN
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP;
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 268437888 bytes
Database Buffers 146800640 bytes
Redo Buffers 6094848 bytes
Database mounted.
Database opened.
SQL> AUDIT ALL BY scott BY ACCESS;
Audit succeeded.
SQL> AUDIT SELECT TABLE, UPDATE TABLE, INSERT TABLE, DELETE TABLE BY scott BY ACCESS;
Audit succeeded.
SQL> AUDIT EXECUTE PROCEDURE BY scott BY ACCESS;
Audit succeeded.
SQL> conn scott/tiger
Connected.
SQL> CREATE TABLE test_tab (
id NUMBER
);
SQL>INSERT INTO test (id) VALUES (1);
SQL>UPDATE test SET id = id;
SQL>SELECT * FROM test;
SQL>DELETE FROM test;
SQL>DROP TABLE test;
Table created.
SQL>
1 row created.
SQL>
1 row updated.
SQL>
ID
----------
1
SQL>
1 row deleted.
SQL>
Table dropped.
SQL>conn /as sysdba
SQL>SELECT view_name
FROM dba_views
WHERE view_name LIKE 'DBA%AUDIT%'
ORDER BY view_name;
VIEW_NAME
------------------------------
DBA_AUDIT_EXISTS
DBA_AUDIT_OBJECT
DBA_AUDIT_POLICIES
DBA_AUDIT_POLICY_COLUMNS
DBA_AUDIT_SESSION
DBA_AUDIT_STATEMENT
DBA_AUDIT_TRAIL
DBA_COMMON_AUDIT_TRAIL
DBA_FGA_AUDIT_TRAIL
DBA_OBJ_AUDIT_OPTS
DBA_PRIV_AUDIT_OPTS
DBA_REPAUDIT_ATTRIBUTE
DBA_REPAUDIT_COLUMN
DBA_STMT_AUDIT_OPTS
SQL>set lines 1000
COLUMN username FORMAT A10
COLUMN owner FORMAT A10
COLUMN obj_name FORMAT A10
COLUMN extended_timestamp FORMAT A35
SQL>SELECT username,
extended_timestamp,
owner,
obj_name,
action_name
FROM dba_audit_trail /*** view as per your Audit_trail option for example for
WHERE owner = 'SCOTT' xml option v$xml_audit_trail ***/
ORDER BY timestamp;
USERNAME EXTENDED_TIMESTAMP OWNER OBJ_NAME ACTION_NAME
---------- ----------------------------------- ---------- ---------- ----------------------------
SCOTT 04-JUL-13 12.30.41.310309 PM +05:30 SCOTT TEST_TAB CREATE TABLE
SCOTT 04-JUL-13 12.30.41.451926 PM +05:30 SCOTT TEST_TAB INSERT
SCOTT 04-JUL-13 12.30.41.457726 PM +05:30 SCOTT TEST_TAB UPDATE
SCOTT 04-JUL-13 12.30.41.460754 PM +05:30 SCOTT TEST_TAB SELECT
SCOTT 04-JUL-13 12.30.41.464694 PM +05:30 SCOTT TEST_TAB DELETE
SCOTT 04-JUL-13 12.30.55.593675 PM +05:30 SCOTT TEST_TAB DROP TABLE
*********END***************
we set this auditing policy to check if any unwanted operation has been performed on production database.
so my this post shows you how to start auditing on purticular table and user operation.
SQL> SHOW PARAMETER AUDIT
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/db11g/ad
ump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string DB
AUDIT_TRAIL = { none | os | db | db,extended | xml | xml,extended }
The following list provides a description of each setting:
none or false - Auditing is disabled.
db or true - Auditing is enabled, with all audit records stored in the database audit trial (SYS.AUD$).
db,extended - As db, but the SQL_BIND and SQL_TEXT columns are also populated.
xml- Auditing is enabled, with all audit records stored as XML format OS files.
xml,extended - As xml, but the SQL_BIND and SQL_TEXT columns are also populated.
os- Auditing is enabled, with all audit records directed to the operating system's audit trail.
SQL> ALTER SYSTEM SET audit_trail=db SCOPE=SPFILE;
System altered.
SQL> SHUTDOWN
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP;
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 268437888 bytes
Database Buffers 146800640 bytes
Redo Buffers 6094848 bytes
Database mounted.
Database opened.
SQL> AUDIT ALL BY scott BY ACCESS;
Audit succeeded.
SQL> AUDIT SELECT TABLE, UPDATE TABLE, INSERT TABLE, DELETE TABLE BY scott BY ACCESS;
Audit succeeded.
SQL> AUDIT EXECUTE PROCEDURE BY scott BY ACCESS;
Audit succeeded.
SQL> conn scott/tiger
Connected.
SQL> CREATE TABLE test_tab (
id NUMBER
);
SQL>INSERT INTO test (id) VALUES (1);
SQL>UPDATE test SET id = id;
SQL>SELECT * FROM test;
SQL>DELETE FROM test;
SQL>DROP TABLE test;
Table created.
SQL>
1 row created.
SQL>
1 row updated.
SQL>
ID
----------
1
SQL>
1 row deleted.
SQL>
Table dropped.
SQL>conn /as sysdba
SQL>SELECT view_name
FROM dba_views
WHERE view_name LIKE 'DBA%AUDIT%'
ORDER BY view_name;
VIEW_NAME
------------------------------
DBA_AUDIT_EXISTS
DBA_AUDIT_OBJECT
DBA_AUDIT_POLICIES
DBA_AUDIT_POLICY_COLUMNS
DBA_AUDIT_SESSION
DBA_AUDIT_STATEMENT
DBA_AUDIT_TRAIL
DBA_COMMON_AUDIT_TRAIL
DBA_FGA_AUDIT_TRAIL
DBA_OBJ_AUDIT_OPTS
DBA_PRIV_AUDIT_OPTS
DBA_REPAUDIT_ATTRIBUTE
DBA_REPAUDIT_COLUMN
DBA_STMT_AUDIT_OPTS
SQL>set lines 1000
COLUMN username FORMAT A10
COLUMN owner FORMAT A10
COLUMN obj_name FORMAT A10
COLUMN extended_timestamp FORMAT A35
SQL>SELECT username,
extended_timestamp,
owner,
obj_name,
action_name
FROM dba_audit_trail /*** view as per your Audit_trail option for example for
WHERE owner = 'SCOTT' xml option v$xml_audit_trail ***/
ORDER BY timestamp;
USERNAME EXTENDED_TIMESTAMP OWNER OBJ_NAME ACTION_NAME
---------- ----------------------------------- ---------- ---------- ----------------------------
SCOTT 04-JUL-13 12.30.41.310309 PM +05:30 SCOTT TEST_TAB CREATE TABLE
SCOTT 04-JUL-13 12.30.41.451926 PM +05:30 SCOTT TEST_TAB INSERT
SCOTT 04-JUL-13 12.30.41.457726 PM +05:30 SCOTT TEST_TAB UPDATE
SCOTT 04-JUL-13 12.30.41.460754 PM +05:30 SCOTT TEST_TAB SELECT
SCOTT 04-JUL-13 12.30.41.464694 PM +05:30 SCOTT TEST_TAB DELETE
SCOTT 04-JUL-13 12.30.55.593675 PM +05:30 SCOTT TEST_TAB DROP TABLE
*********END***************
Wednesday, 3 July 2013
user managed database cloning in oracle
Some time our need is to create clone database of current database for developing purpose.
simple meaning of clone database is to create same database on same server or different server
with same name or different name.so my this blog post describe you how to create user managed database cloning in oracle ?
example:-
ip address: 192.168.128.135 (target database ip address)
: 192.168.128.136 (source database ip address)
database name: db11g
[oracle@oracle@example]$ export ORACLE_SID=db11g
[oracle@oracle@example]$ echo $ORACLE_SID
db11g
[oracle@oracle@example]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 4 10:06:56 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: /as sysdba
Connected to an idle instance.
SQL> alter database backup controlfile to trace as '/u01/archivelog/control.sql'; (take backup of controlfile to trace using this command)
Database altered.
SQL>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
(make directory structure on source database server same as target database server)
:- On source database (192.168.128.136)
[oracle@oracle@example]$mkdir -p /u01/app/oracle/oradata/dupli
[oracle@oracle@example]$mkdir -p /u01/app/oracle/admin/dupli
[oracle@oracle@example]$cd /u01/app/oracle/admin/dupli
[oracle@oracle@example dupli]$ mkdir -p adump dpdump pfile
(transfer data from target database to source database example all datafile,redolog file,trace file(not cotrolfile). also modify trace file as below. use SET and RESETLOGS parameter )
CREATE CONTROLFILE SET DATABASE "db11g" RESETLOGS
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/db11g/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/db11g/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/oradata/db11g/redo03.log' SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/db11g/system01.dbf',
'/u01/app/oracle/oradata/db11g/sysaux01.dbf',
'/u01/app/oracle/oradata/db11g/undotbs01.dbf',
'/u01/app/oracle/oradata/db11g/users01.dbf'
CHARACTER SET WE8MSWIN1252
;
--
(save the file)
[oracle@oracle@example pfile]$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwdupli force=y
Enter password for SYS:
[oracle@oracle@example pfile]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/db_1
[oracle@oracle@example pfile]$ export ORACLE_SID=db11g
[oracle@oracle@example pfile]$ echo $ORACLE_SID
db11g
[oracle@oracle@example pfile]$sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 4 10:06:56 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: /as sysdba
Connected to an idle instance.
SQL> startup nomount pfile='/u01/app/oracle/admin/dupli/pfile/init.ora.6420139223';
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 260049280 bytes
Database Buffers 155189248 bytes
Redo Buffers 6094848 bytes
SQL> @'/u01/archivelog/control.sql'; (run modify tracefile)
Control file created.
SQL> alter database open resetlogs;
Database altered.
SQL> select name,OPEN_MODE from v$database;
NAME OPEN_MODE
--------- --------------------
DB11G READ WRITE
SQL>
********END*********
simple meaning of clone database is to create same database on same server or different server
with same name or different name.so my this blog post describe you how to create user managed database cloning in oracle ?
example:-
ip address: 192.168.128.135 (target database ip address)
: 192.168.128.136 (source database ip address)
database name: db11g
[oracle@oracle@example]$ export ORACLE_SID=db11g
[oracle@oracle@example]$ echo $ORACLE_SID
db11g
[oracle@oracle@example]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 4 10:06:56 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: /as sysdba
Connected to an idle instance.
SQL> alter database backup controlfile to trace as '/u01/archivelog/control.sql'; (take backup of controlfile to trace using this command)
Database altered.
SQL>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
(make directory structure on source database server same as target database server)
:- On source database (192.168.128.136)
[oracle@oracle@example]$mkdir -p /u01/app/oracle/oradata/dupli
[oracle@oracle@example]$mkdir -p /u01/app/oracle/admin/dupli
[oracle@oracle@example]$cd /u01/app/oracle/admin/dupli
[oracle@oracle@example dupli]$ mkdir -p adump dpdump pfile
(transfer data from target database to source database example all datafile,redolog file,trace file(not cotrolfile). also modify trace file as below. use SET and RESETLOGS parameter )
CREATE CONTROLFILE SET DATABASE "db11g" RESETLOGS
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/db11g/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/db11g/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/oradata/db11g/redo03.log' SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/db11g/system01.dbf',
'/u01/app/oracle/oradata/db11g/sysaux01.dbf',
'/u01/app/oracle/oradata/db11g/undotbs01.dbf',
'/u01/app/oracle/oradata/db11g/users01.dbf'
CHARACTER SET WE8MSWIN1252
;
--
(save the file)
[oracle@oracle@example pfile]$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwdupli force=y
Enter password for SYS:
[oracle@oracle@example pfile]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/db_1
[oracle@oracle@example pfile]$ export ORACLE_SID=db11g
[oracle@oracle@example pfile]$ echo $ORACLE_SID
db11g
[oracle@oracle@example pfile]$sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 4 10:06:56 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: /as sysdba
Connected to an idle instance.
SQL> startup nomount pfile='/u01/app/oracle/admin/dupli/pfile/init.ora.6420139223';
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 260049280 bytes
Database Buffers 155189248 bytes
Redo Buffers 6094848 bytes
SQL> @'/u01/archivelog/control.sql'; (run modify tracefile)
Control file created.
SQL> alter database open resetlogs;
Database altered.
SQL> select name,OPEN_MODE from v$database;
NAME OPEN_MODE
--------- --------------------
DB11G READ WRITE
SQL>
********END*********
Thursday, 27 June 2013
how many bytes take by varchar2 data type in oracle to store number or string values.
When we define varchar2 data type to particular column in table, same time we define its length or you can say its range but knowledge point is how many byte oracle server take? to store particular string or number values its depend upon the character set .So my this post explain to you how many byte oracle server take to store values.
Explanation:-
SQL> create table test(id varchar2(10);
table created
SQL> insert into test values('abcdefghij');
one row inserted
SQL>commit;
SQL> select length ('abcdefghij') from dual; **/ length is 10 so no error has been generated after execution of insert statement /*****
SQL> insert into test values('1234567891');
one row inserted
SQL> commit;
SQL> select length('1234567891') from dual; **/ length is 10 so no error has been generated after execution of insert statement /*****
LENGTH('1234567891')
--------------------
10
SQL>insert into test values('12345678910');
ERROR at line 1:
ORA-12899: value too large for column "SCOTT"."TEST"."ID" (actual: 11, maximum:
10)
**/ After execution of statement oracle server gives error because insert statement cross specified range /***
NOTE:- that's means oracle server allowed you to insert only number of numeric and string values as per you specified range of column while creation of table.
SQL> create table test1 (id VARCHAR2(10 byte));
Table created.
note:- now oracle server take only10byte data that means insert only those numeric and string values which within 10 bytes.if numeric or string values cross 10 byte range then oracle server gives error.
Explanation:-
SQL> create table test(id varchar2(10);
table created
SQL> insert into test values('abcdefghij');
one row inserted
SQL>commit;
SQL> select length ('abcdefghij') from dual; **/ length is 10 so no error has been generated after execution of insert statement /*****
SQL> insert into test values('1234567891');
one row inserted
SQL> commit;
SQL> select length('1234567891') from dual; **/ length is 10 so no error has been generated after execution of insert statement /*****
LENGTH('1234567891')
--------------------
10
SQL>insert into test values('12345678910');
ERROR at line 1:
ORA-12899: value too large for column "SCOTT"."TEST"."ID" (actual: 11, maximum:
10)
**/ After execution of statement oracle server gives error because insert statement cross specified range /***
NOTE:- that's means oracle server allowed you to insert only number of numeric and string values as per you specified range of column while creation of table.
SQL> create table test1 (id VARCHAR2(10 byte));
Table created.
note:- now oracle server take only10byte data that means insert only those numeric and string values which within 10 bytes.if numeric or string values cross 10 byte range then oracle server gives error.
how to kill process which is running on particular session.
Some time we needs to terminate current process which is running on particular users session.in this process first we find out which process is running on particular session then we first get it id and serial number,through this two attribute we can kill the oracle process.
note:- this process is very important to kill oracle process without any impact.
Oracle session process kill steps:-
SQL>SET LINESIZE 100
COLUMN spid FORMAT A10
COLUMN username FORMAT A10
COLUMN program FORMAT A45
SELECT s.inst_id,
s.sid,
s.serial#,
p.spid,
s.username,
s.program
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE s.type != 'BACKGROUND';
SQL> ALTER SYSTEM KILL SESSION 'sid,serial#';
In a RAC environment, you optionally specify the INST_ID, shown when querying the GV$SESSION view. This allows you to kill a session on different RAC node.
SQL> ALTER SYSTEM KILL SESSION 'sid,serial#,@inst_id';
The KILL SESSION command doesn't actually kill the session. It merely asks the session to kill itself. In some situations, like waiting for a reply
from a remote database or rolling back transactions, the session will not kill itself immediately and will wait for the current operation to complete.
In these cases the session will have a status of "marked for kill". It will then be killed as soon as possible.
SQL> ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
*************END*************
note:- this process is very important to kill oracle process without any impact.
Oracle session process kill steps:-
SQL>SET LINESIZE 100
COLUMN spid FORMAT A10
COLUMN username FORMAT A10
COLUMN program FORMAT A45
SELECT s.inst_id,
s.sid,
s.serial#,
p.spid,
s.username,
s.program
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE s.type != 'BACKGROUND';
SQL> ALTER SYSTEM KILL SESSION 'sid,serial#';
In a RAC environment, you optionally specify the INST_ID, shown when querying the GV$SESSION view. This allows you to kill a session on different RAC node.
SQL> ALTER SYSTEM KILL SESSION 'sid,serial#,@inst_id';
The KILL SESSION command doesn't actually kill the session. It merely asks the session to kill itself. In some situations, like waiting for a reply
from a remote database or rolling back transactions, the session will not kill itself immediately and will wait for the current operation to complete.
In these cases the session will have a status of "marked for kill". It will then be killed as soon as possible.
SQL> ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
*************END*************
Create database link using host:port/service new syntax
when we want to access data from different database that time we use database link through service name to access particular data.so my this post is for to create database link without change in to tnsname.ora file that means without using service name.
Example:-
Targate Database: orcl
Source Database : test
1)target database
SQL>create user test
identified by test
default tablespace test;
SQL>grant connect,resource to test;
SQL> connect scott/tiger;
SQL> create table test(id number);
SQL>begin
for i in 1..10 loop
insert into test values(i);
end loop;
end;
/
SQL> commit;
SQL> select count(*) from test;
COUNT(*)
----------
10
SQL>
2)Source Database
SQL> CREATE DATABASE LINK test_db_link
CONNECT TO scott IDENTIFIED BY tiger
USING '192.168.128.135:1521/db11g'; ---(use ip address or host_name which you specified in listener file)
SQL>select * from test@test_link;
COUNT(*)
----------
10
********END*************
Example:-
Targate Database: orcl
Source Database : test
1)target database
SQL>create user test
identified by test
default tablespace test;
SQL>grant connect,resource to test;
SQL> connect scott/tiger;
SQL> create table test(id number);
SQL>begin
for i in 1..10 loop
insert into test values(i);
end loop;
end;
/
SQL> commit;
SQL> select count(*) from test;
COUNT(*)
----------
10
SQL>
2)Source Database
SQL> CREATE DATABASE LINK test_db_link
CONNECT TO scott IDENTIFIED BY tiger
USING '192.168.128.135:1521/db11g'; ---(use ip address or host_name which you specified in listener file)
SQL>select * from test@test_link;
COUNT(*)
----------
10
********END*************
Wednesday, 26 June 2013
Create database link without changing tnsname.ora file.
when we want to access data from different database that time we use database link through service name to access particular data.so my this post is for to create database link without change in to tnsname.ora file that means without using service name.
Example:-
Targate Database: orcl
Source Database : test
1)target database
SQL>create user test
identified by test
default tablespace test;
SQL>grant connect,resource to test;
SQL> connect scott/tiger;
SQL> create table test(id number);
SQL>begin
for i in 1..10 loop
insert into test values(i);
end loop;
end;
/
SQL> commit;
SQL> select count(*) from test;
COUNT(*)
----------
10
SQL>
2)Source Database
SQL> create database link test_link
connect to test identified by test
using using
'(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.135)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db11g)
)
)' ;
SQL>select * from test@test_link;
COUNT(*)
----------
10
********END*************
Example:-
Targate Database: orcl
Source Database : test
1)target database
SQL>create user test
identified by test
default tablespace test;
SQL>grant connect,resource to test;
SQL> connect scott/tiger;
SQL> create table test(id number);
SQL>begin
for i in 1..10 loop
insert into test values(i);
end loop;
end;
/
SQL> commit;
SQL> select count(*) from test;
COUNT(*)
----------
10
SQL>
2)Source Database
SQL> create database link test_link
connect to test identified by test
using using
'(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.135)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db11g)
)
)' ;
SQL>select * from test@test_link;
COUNT(*)
----------
10
********END*************
Subscribe to:
Posts (Atom)
Login to the database as user C##GGUSER failed because of error Error while trying to retrieve text for error ORA-01804.
Error : 2026-09-19 11:28:18 ERROR OGG-00303 Unable to connect to database using user C##GGUSER@CDB. Ensure that the necessary privileg...
-
OS Details: [oracle@target ~]$ cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.6 (Maipo) [oracle@target ~]$ ...
-
error Details : SQL> alter user C##GGATE default tablespace GGUSER; alter user C##GGATE default tablespace GGUSER * ERROR at line ...
-
Error Details: OGG-14054 Lag from heartbeat table requires DBLOGIN . GGSCI (source.example.com) 5> lag EXTRACT0 2019-07-31 0...