我在 sqlite (table1) 中有这个数据库:
+-----+-------+-------+
| _id | name | level |
+-----+-------+-------+
| 1 | Mike | 3 |
| 2 | John | 2 |
| 3 | Bob | 2 |
| 4 | David | 1 |
| 5 | Tom | 2 |
+-----+-------+-------+
我想创建一个包含 2 级所有元素的视图,然后添加一个新列,指示新表中行的顺序。也就是说,我想要这个结果:
+-------+------+
| index | name |
+-------+------+
| 1 | John |
| 2 | Bob |
| 3 | Tom |
+-------+------+
我努力了:
CREATE VIEW words AS SELECT _id as index, name FROM table1;
但后来我得到:
+-------+------+
| index | name |
+-------+------+
| 2 | John |
| 3 | Bob |
| 5 | Tom |
+-------+------+
我想它应该是这样的:
CREATE VIEW words AS SELECT XXXX as index, name FROM table 1;
我应该用什么代替XXXX
?