A database link is a schema object in one database that enables you to access objects on another database. The other database need not be an Oracle Database system. However, to access non-Oracle systems you must use Oracle Heterogeneous Services. Here example are given from Oracle database to another Oracle database .
CREATE DATABASE LINK "dblink_name"
CONNECT TO user_name
IDENTIFIED BY password
USING sid_name
In Some situation even though user_name,sid_name and password is correct database link created will result to a failure ;this is because Oracle cannot able to get the connection because of some reason ;in-order to meet this situation we want to specify more details for DBLink creation then this script cam be used.
CREATE DATABASE LINK "dblink_name"
CONNECT TO user_name
IDENTIFIED BY 'password'
USING '(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=host_name)(PORT=1521)))
(CONNECT_DATA=(SID=sid_name)))';
Errors
1)
By using DBLink DDL operations are not allowed .Such as Create ,Drop ,Truncate etc
Truncate table TABLENAME@DBLINK
ORA-02021: DDL operations are not allowed on a remote database
2)
If a Table which containing LOB datatypes are not able select using dblink
create table test_db ( fild_db clob,num number)
select * from test_db@convert;
ORA-22992: cannot use LOB locators selected from remote tables
Here only selection of datatypes other than LOB are allowed
select num from test_db@convert; --> This Works Fine.
3)
Before dropping a DBLink all transactions should be end else this error will occur.
ORA-02018: database link of same name has an open connection
---------------------------------
May 21, 2009
May 11, 2009
JOBS /// IsNumeric
Job will execute in a current schema only ;It will not switch between two schemas .
------------------------------
IsNumeric in ORACLE
----------------
select ISNUM from (
select LENGTH(TRIM(TRANSLATE(string1, ' +-.0123456789', ' '))) ISNUM from table_name ) where ISNUM is null
create or replace function isnumeric (param in char) return boolean as
dummy varchar2(100);
begin
dummy:=to_char(to_number(param));
return(true);
exception
when others then
return (false);
end;
/
------------------------------
IsNumeric in ORACLE
----------------
select ISNUM from (
select LENGTH(TRIM(TRANSLATE(string1, ' +-.0123456789', ' '))) ISNUM from table_name ) where ISNUM is null
create or replace function isnumeric (param in char) return boolean as
dummy varchar2(100);
begin
dummy:=to_char(to_number(param));
return(true);
exception
when others then
return (false);
end;
/
Apr 20, 2009
Hidden Table
Create table " " (EMPNO NUMBER(3));
Creates a table with 4 spaces as its name.
When you select the list of tables from all_tables, such tables are not visible.
To access such a table use
Select * From " ";
(Remember you need to give exactly the same number of spaces as you gave while creating the table).
This feature can be used to store information that you feel is confidential for you.
For Example :
You might create tables of this kind
2 spaces + "MYTAB" + 1 space + "FILE" + 3 spaces
When you create such a table only you know how to access it (Unless someone is intelligent than you to guess it).
Creates a table with 4 spaces as its name.
When you select the list of tables from all_tables, such tables are not visible.
To access such a table use
Select * From " ";
(Remember you need to give exactly the same number of spaces as you gave while creating the table).
This feature can be used to store information that you feel is confidential for you.
For Example :
You might create tables of this kind
2 spaces + "MYTAB" + 1 space + "FILE" + 3 spaces
When you create such a table only you know how to access it (Unless someone is intelligent than you to guess it).
Apr 18, 2009
Export Acess to Oracle
This topic deals with the exporting the table and its data from Access to Oracle database . For this first you need is to create a datasource from Start>Programs>Your Oracle Home program>Configuration and Migration Tools path (or from Start>Settings>Control Panel>Administrative Tools you will see a utility named'Data Sources (ODBC)'), you will see a utility named 'Microsoft ODBC Administrator'. Launch that utility to begin the process.
Click on the Add button to add a new data source.
If your connection test was successful, you will see the following:
Then Open the Access file that u want to Export to Oracle .Then at a time only one table in an Access file can be exported to Oracle .After opening Access(.mdb) file select a table say(ie: TEST) and right click the TABLE in OBJECT and select EXPORT
In the status bar of Access file at this time instead of READY status it will show EXPORT
after completing this without error go and check in your oracle database the access table and data will be exported to oracle
Click on the Add button to add a new data source.
If your connection test was successful, you will see the following:
Then Open the Access file that u want to Export to Oracle .Then at a time only one table in an Access file can be exported to Oracle .After opening Access(.mdb) file select a table say(ie: TEST) and right click the TABLE in OBJECT and select EXPORT
In the status bar of Access file at this time instead of READY status it will show EXPORT
after completing this without error go and check in your oracle database the access table and data will be exported to oracle
Apr 9, 2009
Table Creation/// NOT NULL (check constraint)
Everything (Table Creation including Primary ,Foreign key ,Check constraint and giving user defined CONSTRAINT NAME for NOT NULL CONSTRAINT) in a single Script ;without using alter command for predefined constraints till design time
CREATE TABLE STUDENTS_MAST(
N_STUDID NUMBER(5),CONSTRAINT PK_STUDID PRIMARY KEY(N_STUDID))
CREATE TABLE STUDENT_TEAM (
N_STDTMID NUMBER(10) ,CONSTRAINT PK_STUDENT_TEAM PRIMARY KEY(N_STUDTMID),
N_STUDID NUMBER(10),CONSTRAINT FK_STUD_TEAM_EMPID FOREIGN KEY(N_STUDID) REFERENCES STUDENTS_MAST(N_STUDID),
C_TLFLAG CHAR(1) ,CONSTRAINT CK_STUD_TEAM_TLFLAG CHECK (C_TLFLAG IN ('Y','N')) ,
D_STDATE DATE CONSTRAINT NN_STUD_TEAM_STDATE NOT NULL,
D_ENDDATE DATE CONSTRAINT NN_STUD_TEAM_ENDATE NOT NULL,
D_ENTRYDAT DATE DEFAULT SYSDATE )
--------------
CREATE TABLE STUDENT_TEAM (N_STDTMID NUMBER(10) CONSTRAINT NN_STUDENT_STATUS_TMID NOT NULL)
ALTER TABLE STUDENT_STATUS ADD ( CONSTRAINT NN_ST_STATUS_TMID CHECK (N_STDTMID IS NOT NULL))
Both Scripts will restrict not null values but error code will be different first script results
ORA-01407: cannot update to NULL
ORA-01400: cannot insert NULL into N_STDTMID
second script results
Another difference is the null(nullable) field will be true when null is checked by first script but it will not be for second second script
-----------
During check constraint creation if already exists some records in the particular table which violates the new check constraint.This error will be displayed
ORA-02293: cannot validate (##########) - check constraint violated
-----------------
CREATE TABLE STUDENTS_MAST(
N_STUDID NUMBER(5),CONSTRAINT PK_STUDID PRIMARY KEY(N_STUDID))
CREATE TABLE STUDENT_TEAM (
N_STDTMID NUMBER(10) ,CONSTRAINT PK_STUDENT_TEAM PRIMARY KEY(N_STUDTMID),
N_STUDID NUMBER(10),CONSTRAINT FK_STUD_TEAM_EMPID FOREIGN KEY(N_STUDID) REFERENCES STUDENTS_MAST(N_STUDID),
C_TLFLAG CHAR(1) ,CONSTRAINT CK_STUD_TEAM_TLFLAG CHECK (C_TLFLAG IN ('Y','N')) ,
D_STDATE DATE CONSTRAINT NN_STUD_TEAM_STDATE NOT NULL,
D_ENDDATE DATE CONSTRAINT NN_STUD_TEAM_ENDATE NOT NULL,
D_ENTRYDAT DATE DEFAULT SYSDATE )
--------------
CREATE TABLE STUDENT_TEAM (N_STDTMID NUMBER(10) CONSTRAINT NN_STUDENT_STATUS_TMID NOT NULL)
ALTER TABLE STUDENT_STATUS ADD ( CONSTRAINT NN_ST_STATUS_TMID CHECK (N_STDTMID IS NOT NULL))
Both Scripts will restrict not null values but error code will be different first script results
ORA-01407: cannot update to NULL
ORA-01400: cannot insert NULL into N_STDTMID
second script results
Another difference is the null(nullable) field will be true when null is checked by first script but it will not be for second second script
-----------
During check constraint creation if already exists some records in the particular table which violates the new check constraint.This error will be displayed
ORA-02293: cannot validate (##########) - check constraint violated
-----------------
Subscribe to:
Posts (Atom)