Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008
    Posts
    16

    Unanswered: create table select option Issue

    I have created a copy of an exisitng table in the database as -

    create table test1_temp as select * from test1 where 1=2;

    The table was created w/o data.
    But the problem is that the indexes and primary key of table "test1" are not copied to "test1_temp".

    Since the table ddl is copied dynamically, I want to copy the indexes and primary keys also dynamically. How should I achieve this.

    Pls help.Thanks.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by Hello1
    Since the table ddl is copied dynamically, I want to copy the indexes and primary keys also dynamically. How should I achieve this.
    You can't.
    You must run a proper CREATE TABLE in primary an foreign keys.
    And you must run a CREATE INDEX to defined non-pk indexes

Posting Permissions

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