Skip to Main Content
  • Questions
  • DB link is not working between 2 databases

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Ankit.

Asked: November 14, 2018 - 11:19 am UTC

Last updated: November 15, 2018 - 10:51 am UTC

Version: 12.1.0.1

Viewed 1000+ times

You Asked

Hi,

We have 2 databases DB A and DB B. we have created db link between 2 dbs as a2b;

in DB A, we have below table_A and data,

create table table_a (emp_id number, emp_name varchar2(30))
/

insert into table_a values (1,'Test1')
/
insert into table_a values (2,'Test2')
/
insert into table_a values (3,'Test3')
/
insert into table_a values (4,'Test4')
/
insert into table_a values (5,'Test5')
/

commit
/


in DB B, we have below table_B,

create table table_B (emp_id number, emp_name varchar2(30))
/


Now we want to add data from table_A to table_B using a2b db link,

we have tried by below DML statement but it's giving error as "ORA-01031 insufficient privilages" "ORA-02063 preceding line from a2b"

DML: insert into table_b@a2b(emp_id,emp_name) select * from table_a; but it's giving above error

please suggest.

Thanks


and Chris said...

ORA-01031 => you're lacking privileges to run the statement. Probably insert on table_b.

Presumably this is because the database link connects to DB B as a user that

- Doesn't own table_B
- Has no insert privileges on table_B

So check which user you connect as and whether this has the right privileges:

select username 
from   dba_db_links
where  db_link = 'A2B';


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

continuation with previous post

Ankit Bhatt, November 15, 2018 - 6:14 am UTC

we have given all privileges to A2B db link but still not able to insert.

whether insert statement is correct or not?

Thanks
Chris Saxon
November 15, 2018 - 10:51 am UTC

It's a privilege error. So something is wrong with your permissions somewhere.

Break it down. Run a single row insert over the db link (insert ... values ...). And query the local table. Which of these statements fail?

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database