Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Any way to copy a table using SQL?
Mon, Feb 1 2010 4:12 PMPermanent Link

Dave
I have a table called TableX. I'd like to use SQL to create a copy of it.

Example:
create table TableXBU select * from TableX;

or

create table TableXBU like TableX;
insert into TableXBU select * from TableX;

Unfortunately none of these work. Is there a simple SQL alternative to copy a table?
TIA
Dave
Mon, Feb 1 2010 4:20 PMPermanent Link

"Robert"

"Dave" <dbguy@2-mail.com> wrote in message
news:12F68EE7-3747-4F56-8B76-0114ADDA9D76@news.elevatesoft.com...
>I have a table called TableX. I'd like to use SQL to create a copy of it.
>
> Example:
> create table TableXBU select * from TableX;
>
> or
>
> create table TableXBU like TableX;
> insert into TableXBU select * from TableX;
>
> Unfortunately none of these work. Is there a simple SQL alternative to
> copy a table?

SELECT INTO - but it will not copy the indexes, you need to add the
appropriate create index.

Robert

Tue, Feb 2 2010 11:12 AMPermanent Link

Dave
"Robert" wrote:


"Dave" <dbguy@2-mail.com> wrote in message
news:12F68EE7-3747-4F56-8B76-0114ADDA9D76@news.elevatesoft.com...
>I have a table called TableX. I'd like to use SQL to create a copy of it.
>
> Example:
> create table TableXBU select * from TableX;
>
> or
>
> create table TableXBU like TableX;
> insert into TableXBU select * from TableX;
>
> Unfortunately none of these work. Is there a simple SQL alternative to
> copy a table?

SELECT INTO - but it will not copy the indexes, you need to add the
appropriate create index.

Robert


Robert,
   The "select Into ..." is what I'm looking for. Thanks.

Dave
Image