Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SELECT INTO statement in sqlite

Tags:

sqlite

Does sqlite support the SELECT INTO statement?

Actually I am trying to save the data in table1 into table2 as a backup of my database before modifying the data.

When I try using the SELECT INTO statement:

SELECT * INTO equipments_backup FROM equipments; 

I get a syntax error:

"Last Error Message:near "INTO":syntax error".

like image 768
monish Avatar asked Mar 02 '10 09:03

monish


People also ask

Does SQLite support SELECT into?

sqlite does not support SELECT INTO.

What is SELECT into statement?

The SELECT INTO statement is a query that allows you to create a new table and populate it with the result set of a SELECT statement . To add data to an existing table, see the INSERT INTO statement instead. SELECT INTO can be used when you are combining data from several tables or views into a new table.

How do I SELECT specific data in SQLite?

To select data from an SQLite database, use the SELECT statement. When you use this statement, you specify which table/s to select data from, as well as the columns to return from the query. You can also provide extra criteria to further narrow down the data that is returned.

How do I SELECT two columns in SQLite?

To select multiple columns from a table, simply separate the column names with commas! For example, this query selects two columns, name and birthdate , from the people table: SELECT name, birthdate FROM people; Sometimes, you may want to select all columns from a table.


2 Answers

Instead of

SELECT * INTO equipments_backup FROM equipments 

try

CREATE TABLE equipments_backup AS SELECT * FROM equipments 
like image 125
user343574 Avatar answered Sep 21 '22 16:09

user343574


sqlite does not support SELECT INTO.

You can probably use this form instead:

INSERT INTO equipments_backup SELECT * FROM equipments;

like image 37
nos Avatar answered Sep 25 '22 16:09

nos