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

查看:97
本文介绍了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天全站免登陆