SQLite多个自动增量列? [英] SQLite multiple Autoincrement Columns?

查看:40
本文介绍了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多个自动增量列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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