SQLite multiple Autoincrement Columns?(SQLite多个自动增量列?)
问题描述
我尝试使用以下 SQL 来创建表和一些列.作为其中的一部分,我希望其中两列自动递增一个整数.当我尝试使用下面的代码时,它给了我一个错误.
I have the below SQL I am trying to use to create a table and some columns. As part of it, I want two of the columns to autoincrement an integer. When I try using the below code it gives me an error.
CREATE TABLE IF NOT EXISTS 'tasks' (
'rowID' INTEGER,
'gID' INTEGER,
'task' TEXT,
'status' TEXT,
'position' INTEGER,
'updated' INTEGER,
'inlist' TEXT,
'deleted' TEXT,
PRIMARY KEY AUTOINCREMENT ('rowID','position')
)
当我从 SQL 中删除关键字AUTOINCREMENT"时,它可以正常工作.
When I remove the keyword "AUTOINCREMENT" from the SQL it works fine.
是否可以有两个自增列?如果没有,有没有一种方法可以让一列在插入时自动从另一列(自动递增)中获取值?
Is it possible to have two autoincrementing columns? If not, is there a way I can have one column automatically take the value from the other (auto-incrementing) column as its being inserted?
谢谢
推荐答案
你不能有两个自增字段.您应该使用单个自动增量字段.鉴于这两个字段对于每一行总是具有相同的值,因此没有理由必须使用这些字段.
You can't have two autoincrement fields. You should use a single autoincrement field. Given that both fields would always have the same value for every row, there's no reason to have to such fields anyway.
这篇关于SQLite多个自动增量列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQLite多个自动增量列?
基础教程推荐
- SQL Server 2016更改对象所有者 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01