开发者

create a table from another and a literal

开发者 https://www.devze.com 2023-01-15 10:57 出处:网络
I\'m working with sqlite and trying to create a table from another. This works: create table sources_tmp as select \"literal\" system,name,user from sources;

I'm working with sqlite and trying to create a table from another.

This works:

create table sources_tmp as select "literal" system,name,user from sources;

but it doesn't allow 开发者_JAVA百科me to specify the type for the "literal".

I've tried this but doesn't work that way apparently:

create table sources_tmp as select "literal" system as $TYPE,name,user from sources;


Use CAST(). "AS" means something else. Example:

CREATE TABLE TEST(ID INT, NAME VARCHAR);
INSERT INTO TEST VALUES(1, '10');
CREATE TABLE TEST2 AS 
SELECT CAST(ID AS VARCHAR) A, CAST(NAME AS INT) X FROM TEST;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号