1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

copy one table data to another table

Discussion in 'SQL PL/SQL' started by arun888, Jun 12, 2015.

  1. arun888

    arun888 Guest

    hi all,

    i am not expert in oracle language. can anyone tell me how to copy one table data to another table.

    i will be providing the inputs for source table and destination table.

    please help me out.
     
  2. eras

    eras Active Member

    Messages:
    23
    Likes Received:
    9
    Trophy Points:
    90
    Location:
    Lithuania
    Code (SQL):

    INSERT INTO another_table(col_a1, col_a2, col_a3, ....)
    SELECT col_o1, col_o2, col_o3 FROM one_table
     
     
    arun888 likes this.
  3. Naveen Rachapally

    Naveen Rachapally Active Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    50
    Location:
    India
    Hi Arun,

    If you copy the entire database into new table, then simply we can do as follows:

    create table <new_table> as select * from <schema_name>.<old_table_name>

    SQL> create table emp (name varchar2(10),empid number);

    Table created.

    SQL> insert into emp values ('NAME1',1);

    1 row created.

    SQL> create table emp1 as select * from emp;

    Table created.

    SQL> select * from emp1;

    NAME EMPID
    ---------- ----------
    NAME1 1

    SQL> desc emp1
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    NAME VARCHAR2(10)
    EMPID NUMBER

    SQL> desc emp
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    NAME VARCHAR2(10)
    EMPID NUMBER

    Hope this will be helpfull.
     
  4. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,345
    Likes Received:
    347
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Honestly it doesn't as the original post clearly states the source and destination tables already exist. A simple

    insert into ...
    select ... from ...

    is all that is needed.

    It helps to read and understand the original question before posting.
     
  5. MUSEFIU

    MUSEFIU Starter

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    10
    Location:
    Nigeria
    To copy your exact data into a new table u just want to create.
    Code (SQL):
    CREATE TABLE TABLE_NAME
    AS
    SELECT * FROM existing_table_name.
    .
    But to copy to an existing table.
    Insert into table_name
    Select column_1,column_2,column_3,column_n
    From existing_table_name.