sách gpt4 ăn đã đi

sql - INT PRIMARY KEY 和 INTEGER PRIMARY KEY SQLite 的区别

In lại 作者:IT王子 更新时间:2023-10-29 06:17:19 27 4
mua khóa gpt4 giày nike

INT PRIMARY KEYINTEGER PRIMARY KEY 在定义表的模式时有什么区别吗?使用 int 主键时,我生成了 sqlite_autoindex thing;当整数主键时,我生成了 sqlite_sequence 表。有什么不同?什么副作用可以有第一个和第二个变体?

câu trả lời hay nhất

更新:SQLite 的 ROWID 列现在是 64-bit integer :

In SQLite, a column with type INTEGER PRIMARY KEY is an alias for the ROWID (except in WITHOUT ROWID tables) which is always a 64-bit signed integer.

hiện hữuSQLite 3 documentation中都有解释:

2.0 The INTEGER PRIMARY KEY

One exception to the typelessness of SQLite is a column whose type is INTEGER PRIMARY KEY. (And you must use "INTEGER" not "INT". A column of type INT PRIMARY KEY is typeless just like any other.) INTEGER PRIMARY KEY columns must contain a 32-bit signed integer. Any attempt to insert non-integer data will result in an error.

INTEGER PRIMARY KEY columns can be used to implement the equivalent of AUTOINCREMENT. If you try to insert a NULL into an INTEGER PRIMARY KEY column, the column will actually be filled with an integer that is one greater than the largest key already in the table. Or if the largest key is 2147483647, then the column will be filled with a random integer. Either way, the INTEGER PRIMARY KEY column will be assigned a unique integer. You can retrieve this integer using the sqlite_last_insert_rowid() API function or using the last_insert_rowid() SQL function in a subsequent SELECT statement.

关于sql - INT PRIMARY KEY 和 INTEGER PRIMARY KEY SQLite 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20289410/

27 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress