SQlite: select into?

SqlSqlite

Sql Problem Overview


I'm not sure if I can use select into to import data from another table like this:

select * into
  bookmark1 
from bookmark;    

Is it true that SQlite doesn't support this syntax? are there any other alternatives?

Sql Solutions


Solution 1 - Sql

You could do:

create table bookmark1 as select * from bookmark;

Solution 2 - Sql

You can try this query:

insert into bookmark1 select * from bookmark

Solution 3 - Sql

I assume that bookmark1 is a new table that you have created which is same as the bookmark table. In that case you can use the following format.

CREATE TABLE bookmark1 AS SELECT * FROM bookmark;

Or you can also use the insert statement with subquery. For different insert statement options refer: SQL As Understood By SQLite

Solution 4 - Sql

create table NewTable as
select * from OldTable where 1 <> 1

This will copy data structure for you.

Solution 5 - Sql

BUT be carefull: "create table" from the other in such a way is not saving Data Types of new table's fields as so as they were in the source table, therefore I would prefer to "create table" with a separate statement & "insert into" statement also to do separately - as was mentioned above:

insert into bookmark_backup select * from bookmark;"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGlauconView Question on Stackoverflow
Solution 1 - SqlvitView Answer on Stackoverflow
Solution 2 - SqlNick DandoulakisView Answer on Stackoverflow
Solution 3 - SqlneoView Answer on Stackoverflow
Solution 4 - SqlWadood ChaudharyView Answer on Stackoverflow
Solution 5 - SqlJeeyCiView Answer on Stackoverflow