Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i insert the data in one schema table to another schema table?

Tags:

oracle

I have two different schemas. Each schema contains different tables. For example a is a table in schema1 and b is table in schema2. Now i want to insert table a data into table b(schema2).

like image 727
user2849710 Avatar asked Mar 20 '23 20:03

user2849710


2 Answers

Login to the user which have access to both the schema and run insert command like,

INSERT INTO schema1.table_name 
     SELECT * FROM schema2.table_name;

Assuming that the tables are identical in both the schema.

like image 56
Dba Avatar answered Mar 24 '23 05:03

Dba


schema1 needs privileges on table in schema2

connect schema2

grant select , insert on b to schema1;

Then

connect schema1

insert into schema2.b select * from a;

Or create a synonym

create synonym b for schema2.b;

insert into b select * from a;
like image 41
Rob van Laarhoven Avatar answered Mar 24 '23 04:03

Rob van Laarhoven