An error occurred: near "AUTO_INCREMENT": syntax error
CREATE TABLE fileInfo
(
fileId int NOT NULL AUTO_INCREMENT,
name varchar(255),
status int NOT NULL,
PRIMARY KEY (fileId)
);
해결 방법
어떤 상태 :
AUTOINCREMENT를 생성하는 방법 들?
짧은 대답 : 선언 된 열 INTEGER PRIMARY KEY will 자동 증가.
여기에 긴 대답이 있습니다. declare a column of a table to be INTEGER PRIMARY KEY, then whenever you insert a NULL into that column of the table, the NULL is automatically converted into an integer which is one greater than the largest value of that column over all other rows in the table, or 1 if the table is empty. (If the largest possible integer key, 9223372036854775807, then an unused key value is chosen at random.) For example, suppose you have a table like 이:
CREATE TABLE t1 (INTEGER PRIMARY
KEY, b INTEGER );
With this table, 진술
INSERT INTO t1 VALUES (NULL, 123);
는 논리적으로 다음과 같은 말과 동일합니다.
INSERT INTO t1 VALUES ((SELECT max (a) FROM t1)+1,123);
There is a function namedsqlite3_last_insert_rowid()
which will return the integer key for 가장 최근의 삽입 작업.정수 키는 1입니다. greater than the largest key that was in the table just prior to the insert. The new key will be unique over all keys currently in the table, but it might overlap with keys that have been previously deleted from the table. To create keys that are unique over the lifetime of the table, add the AUTOINCREMENT keyword to the INTEGER PRIMARY KEY declaration. Then the key chosen will be one more than than the largest key that has ever existed in that table. If the largest possible key has previously existed in that table, then the INSERT will fail with SQLITE_FULL 오류 코드.
참조 페이지 https://stackoverflow.com/questions/508627
'파이썬' 카테고리의 다른 글
파이썬 Error when installing python3 packages in alpine (0) | 2020.10.11 |
---|---|
파이썬 How do you directly overlay a scatter plot on top of a jpg image in matplotlib / Python? (0) | 2020.10.11 |
파이썬 timeit.Timer ()를 사용할 때 함수의 매개 변수를 전달하는 방법 (0) | 2020.10.11 |
파이썬 Python 버전을 업데이트하는 방법은 무엇입니까? (0) | 2020.10.11 |
파이썬 Keras 멀티 클래스 모델에서 혼동 행렬 얻기 (0) | 2020.10.11 |
댓글