开发者

create a table from another and a literal

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜