【发布时间】:2019-03-18 10:32:33
【问题描述】:
我有一个 database.db 文件,其中有一个 table1 像你的那样。请注意,索引只是代码而不是数字:
id | item | price
-------------
45f5 | book | 20
25h8 | copy | 30
as34 | pen | 10
t674 | key | 15
5h6f | ring | 25
67yu | mug | 40
我想在我的 dababase.db 名称 table2 和 table3 中创建两个额外的表,其中一个包含前 4 行,另一个包含最后 2 行:
表2
id | item | price
-------------
45f5 | book | 20
25h8 | copy | 30
as34 | pen | 10
t674 | key | 15
表3
id | item | price
-------------
5h6f | ring | 25
67yu | mug | 40
我一直在尝试使用 CREATE TABLE,但 table1 中的列太多,无法一一写入。你会如何解决这个问题?谢谢!
"CREATE TABLE table2 AS SELECT * FROM table1 WHERE condition"
【问题讨论】:
-
只需手动编写语句或从 SQLite 3 系统表中复制数据:stackoverflow.com/questions/2858519/…