Passing a schema registration to another

DBA Geral (instalação, configuração do banco, scripts do Sql*Plus, shell scripts, batch scripts, etc...)
Post Reply
Cristiano Gomes
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 25
Joined: Fri, 25 May 2007 3:21 pm
Location: São Paulo

Environment information:
* Oracle version: 9i
* Operating system: Windows 2003

Good afternoon,

I have a database that has two equal schemas. I need to copy the contents of a table from a schema to the other. How should I do?

The tables have the same structure, I tried the way below, but I was not happy.

Select all

INSERT INTO TESTE (SELECT * FROM SCHEMA1.TAB) 
VALUES (SELECT * FROM SCHEMA2.TAB)
Thank you
Trevisolli
Moderador
Moderador
Posts: 2016
Joined: Wed, 12 Jan 2005 3:25 pm
Location: Araraquara - SP
Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Brother,

Try in this way:

Select all

 
INSERT INTO schema2.TABLE AS SELECT * FROM schema1.TABLE; 
Cristiano Gomes
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 25
Joined: Fri, 25 May 2007 3:21 pm
Location: São Paulo

I tried this way and Oracle presented the error below.

Select all

ERROR at line 1: 
ORA-00926: missing VALUES keyword
Thank you
iabrj
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Sun, 06 Jan 2008 1:51 pm
Location: Rio de Janeiro - RJ

Try this way:

Select all

INSERT INTO schema1.NomeTabela 
(SELECT * FROM schema2.NomeTabela);
Cristiano Gomes
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 25
Joined: Fri, 25 May 2007 3:21 pm
Location: São Paulo

Good afternoon

I think I need to infomer instead of * the name of the columns, as the tables of the two schemas have the same columns in different order.

Sincerely
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest