Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005

    Unanswered: Copy Table with content into new Table with different Name


    What is the best way to "clone" a table and its contents into a new table with a different name. Is there a way to do it with the system tools or via some SQL-Statement?

  2. #2
    Join Date
    Dec 2003
    North America
    generate the schema for the table you want to clone, change the table-name and index-name(s) in the SQL script, and create a new table that will have exactly the same structure as the original table.

    from the commandline execute this:
    dbschema -d database_name -t table_name > build_table.sql

    then edit the build_table.sql script as previously described and run it.

    use you favorite SQL tool (like dbaccess) and execute this:

    insert into new_table (col1, col2, col3, col4, col5, col6)
    select (col1, col2, col3, col4, col5, col6)
    from original_table

    suggestion if the table is huge:
    1) execute the "create table" statement in build_table.sql to create the new table
    2) insert data into the new table from the original table as described
    3) execute the "create index" statement(s) in build_table.sql

  3. #3
    Join Date
    Oct 2005
    That solved the issue - Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts