[sqlite] SQL Syntax To Copy A Table

2015-03-30 Thread Dominique Devienne
On Thu, Mar 26, 2015 at 4:29 PM, Nigel Verity 
wrote:

> My requirement is to take periodic snapshots of a names and addresses
> table, to be stored in the same database as the master.
>

Perhaps also look into https://www.sqlite.org/backup.html, which doesn't
qualify for "the same database", but seems closer to the spirit of your
requirement. --DD


[sqlite] SQL Syntax To Copy A Table

2015-03-29 Thread Maurizio Trevisani
I suggest to use the CloneTable function
Have a look at
https://www.gaia-gis.it/fossil/libspatialite/wiki?name=CloneTable

It copies the table and all of its triggers, indexes, etc.

Maurizio

2015-03-26 16:35 GMT+01:00, John McKown :
> On Thu, Mar 26, 2015 at 10:29 AM, Nigel Verity 
> wrote:
>> Hi
>>
>> I know this must seem a fairly dumb question, but I can't find an easy way
>> to create a copy of table using just SQL.
>>
>> My requirement is to take periodic snapshots of a names and addresses
>> table, to be stored in the same database as the master.
>>
>> The master table has one index - an auto-incrementing integer ID (non
>> NULL, primary key). There is no need for the corresponding field in the
>> snapshot to be indexed, but the integer ID does need to be copied across.
>>
>> I'm happy to copy the table structure in one operation and the data in
>> another, but if it can be done in a single operation so much the better.
>
> You could use _two_ statements like:
>
> DROP TABLE IF EXISTS copy_of_bubba;
> CREATE TABLE copy_of_bubba AS SELECT * FROM bubba;
>
>>
>> Thanks
>>
>> Nige
>>
>>
>>
>> ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>
>
> --
> If you sent twitter messages while exploring, are you on a textpedition?
>
> He's about as useful as a wax frying pan.
>
> 10 to the 12th power microphones = 1 Megaphone
>
> Maranatha! <><
> John McKown
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] SQL Syntax To Copy A Table

2015-03-26 Thread Martin Engelschalk
Hi Nige,

create table  as select * from 

See also http://www.sqlite.org/lang_createtable.html

Martin

Am 26.03.2015 um 16:29 schrieb Nigel Verity:
> Hi
>
> I know this must seem a fairly dumb question, but I can't find an easy way to 
> create a copy of table using just SQL.
>
> My requirement is to take periodic snapshots of a names and addresses table, 
> to be stored in the same database as the master.
>
> The master table has one index - an auto-incrementing integer ID (non NULL, 
> primary key). There is no need for the corresponding field in the snapshot to 
> be indexed, but the integer ID does need to be copied across.
>
> I'm happy to copy the table structure in one operation and the data in 
> another, but if it can be done in a single operation so much the better.
>
> Thanks
>
> Nige
>
>
>   
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

-- 

*Codeswift GmbH *
Kr?utlerweg 20a
A-5020 Salzburg
Tel: +49 (0) 8662 / 494330
Mob: +49 (0) 171 / 4487687
Fax: +49 (0) 3212 / 1001404
engelschalk at codeswift.com
www.codeswift.com / www.swiftcash.at

Codeswift Professional IT Services GmbH
Firmenbuch-Nr. FN 202820s
UID-Nr. ATU 50576309



[sqlite] SQL Syntax To Copy A Table

2015-03-26 Thread Nigel Verity
Hi

I know this must seem a fairly dumb question, but I can't find an easy way to 
create a copy of table using just SQL.

My requirement is to take periodic snapshots of a names and addresses table, to 
be stored in the same database as the master.

The master table has one index - an auto-incrementing integer ID (non NULL, 
primary key). There is no need for the corresponding field in the snapshot to 
be indexed, but the integer ID does need to be copied across.

I'm happy to copy the table structure in one operation and the data in another, 
but if it can be done in a single operation so much the better.

Thanks

Nige





[sqlite] SQL Syntax To Copy A Table

2015-03-26 Thread John McKown
On Thu, Mar 26, 2015 at 10:29 AM, Nigel Verity  
wrote:
> Hi
>
> I know this must seem a fairly dumb question, but I can't find an easy way to 
> create a copy of table using just SQL.
>
> My requirement is to take periodic snapshots of a names and addresses table, 
> to be stored in the same database as the master.
>
> The master table has one index - an auto-incrementing integer ID (non NULL, 
> primary key). There is no need for the corresponding field in the snapshot to 
> be indexed, but the integer ID does need to be copied across.
>
> I'm happy to copy the table structure in one operation and the data in 
> another, but if it can be done in a single operation so much the better.

You could use _two_ statements like:

DROP TABLE IF EXISTS copy_of_bubba;
CREATE TABLE copy_of_bubba AS SELECT * FROM bubba;

>
> Thanks
>
> Nige
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown