sqlite 插入表 select * from [英] sqlite insert into table select * from

查看:56
本文介绍了sqlite 插入表 select * from的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的 Android 应用中将数据从一个表移动到另一个表

I need to move data from one table to another in my Android app

我想使用以下sql:

insert into MYTABLE2 select id, STATUS risposta, DATETIME('now') data_ins from  MYTABLE 2

不幸的是,在表 MYTABLE2 中有一个 _ID 列 AUTOINCREMENT.我能做什么?

Unfortunately in table MYTABLE2 there is an _ID column AUTOINCREMENT. What could I do?

谢谢.

这是我的 MYTABLE2,我想用另一个表中的数据填充该表:

this is my MYTABLE2 the, the table I would like to populate with data from another table:

CREATE TABLE "ANSWERS" ("_id" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL ,
"ID_QUESTION" INTEGER,"DATE_INS" DATETIME DEFAULT 
(CURRENT_DATE) , "ANSWER" INTEGER)

推荐答案

INSERT子句中明确指定列名,

explicitly specify the column name in the INSERT clause,

INSERT INTO destinationTable (risposta, data_ins)
SELECT STATUS risposta, DATETIME('now') data_ins 
FROM   sourceTable

这篇关于sqlite 插入表 select * from的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆