lulzo
lulzo

Reputation: 67

Creating a sqlite table in terminal (iOS)

sqlite> create table t
...>  SELECT *  FROM sqlite_master WHERE type='table' AND name='t';
Error: near "SELECT": syntax error
sqlite> 

I'm trying to create a table called 't' in terminal. I'm getting the error. Maybe I'm missing somewhere?

Upvotes: 1

Views: 72

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521289

The syntax you need to use here is CREATE TABLE AS ... SELECT:

> CREATE TABLE t AS SELECT * FROM sqlite_master WHERE type = 'table' AND name = 't';

Upvotes: 1

Related Questions