ceving
ceving

Reputation: 23863

What is the Sqlite analogue for table literals as in Postgresql or Sybase?

What is the Sqlite analogue for table literals as in Postgresql or Sybase?

select * from (values (1, 'a'), (2, 'b')) as t(x,y);

Upvotes: 0

Views: 87

Answers (2)

CL.
CL.

Reputation: 180210

Such table literals are supported since version 3.8.3, as part of the common table expression support.

To specify column names, you must use an actual common table expression:

WITH t(x, y) AS (
  VALUES (1, 'a'), (2, 'b')
)
SELECT * FROM t;

Upvotes: 1

user330315
user330315

Reputation:

It's the same in SQLite (tested with 3.14). However the alias specifying the column names is not supported.

So this works:

select * 
from (values (1, 'a'), (2, 'b')) as t;

I don't know how to specify the alias for the columns though.

Upvotes: 1

Related Questions