Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread How to copy table using SQL?
Fri, Mar 2 2007 11:50 AMPermanent Link

Sam Davis
Some databases can copy a table using sql like:

create table newtable select * from oldtable;

or

create table newtable like oldtable;

Is it possible to do this in DBISAM?

TIA
Sam
Fri, Mar 2 2007 12:33 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sam

SELECT INTO

I can never remember the formant so check it out in the manual


Roy Lambert
Fri, Mar 2 2007 1:22 PMPermanent Link

"Robert"

"Sam Davis" <sammyd432@yahoo.com> wrote in message
news:F92F49DF-43BC-47E0-AA1F-366FBD081137@news.elevatesoft.com...
> Some databases can copy a table using sql like:
>
> create table newtable select * from oldtable;
>
> or
>
> create table newtable like oldtable;
>
> Is it possible to do this in DBISAM?
>

AFAIK, you can not copy the indexes you will have to create them. Otherwise,
for the table structure and the data, is is simply

SELECT * FROM OLDTABLE INTO NEWTABLE;

If you want an empty table, add an impossible WHERE clause, such as WHERE
FALSE = TRUE

Robert

Sat, Mar 3 2007 2:52 AMPermanent Link

Sam Davis
Roy Lambert wrote:

> Sam
>
> SELECT INTO
>
> I can never remember the formant so check it out in the manual
>
>
> Roy Lambert
>

Roy,
    I found it.

select * into tablenew from tableold;

which has the phrases in the opposite order from what I'm used to.  At
least it works. Smile

Sam
Sat, Mar 3 2007 11:55 AMPermanent Link

"Johnnie Norsworthy"
"Sam Davis" <sammyd432@yahoo.com> wrote in message
news:55589CB1-C05F-4490-A772-3D80A04C718B@news.elevatesoft.com...
> select * into tablenew from tableold;

Don't forget to create indexes if they are needed.

Sat, Mar 3 2007 11:59 AMPermanent Link

Sam Davis
Johnnie Norsworthy wrote:
> "Sam Davis" <sammyd432@yahoo.com> wrote in message
> news:55589CB1-C05F-4490-A772-3D80A04C718B@news.elevatesoft.com...
>
>>select * into tablenew from tableold;
>
>
> Don't forget to create indexes if they are needed.
>
>

Correct and I guess I'll have to do that manually. In MySQL they have a:

   create table newtable like oldtable;

which is create the table structure including the indexes which is nice.
As for now, I'm just using this SQL to create a backup of the data so I
can eliminate the indexes for now.

Thanks for the help. Smile

Sam
Mon, Mar 5 2007 9:42 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Sam,

<< Some databases can copy a table using sql like:

create table newtable select * from oldtable;

or

create table newtable like oldtable;

Is it possible to do this in DBISAM? >>

As mentioned already, use SELECT..INTO for this in DBISAM.   ElevateDB
offers CREATE TABLE AS and CREATE TABLE LIKE operations.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image