DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: copy the structure of a table

  1. #1
    Join Date
    Apr 2002
    Posts
    34

    copy the structure of a table

    Hi

    I want to create another table which is having the structure same as an existing table. How do I do that? Please note I just want the structure of an existing table and not the data in it.

    Please help. Thanks in advance

  2. #2
    Join Date
    Nov 2002
    Posts
    170
    There are several ways to do it....the easiest way would be

    Create table xxx (you can also use storage clause here )
    as
    select * from yyy;

    Then truncate table xxx;

  3. #3
    Join Date
    Jan 2001
    Posts
    3,134
    SQL> create table blah_copy as
    select * from blah
    where 1=2;

    That's it

    MH
    I remember when this place was cool.

  4. #4
    Join Date
    Jan 2001
    Posts
    3,134
    Originally posted by dbasupuser
    There are several ways to do it....the easiest way would be

    Create table xxx (you can also use storage clause here )
    as
    select * from yyy;

    Then truncate table xxx;
    Sorry but that is very inefficient, especially if it is a large table.
    Just use "where 1=2" since this condition will never be true no rows are copied

    MH
    I remember when this place was cool.

  5. #5
    Join Date
    Jul 2002
    Location
    Washington DC
    Posts
    110
    or

    create table blah_copy as
    select * from blah where rowid is null;

Posting Permissions

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


Click Here to Expand Forum to Full Width