3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sqliteのupdateはlimit出来ない

Last updated at Posted at 2015-03-11

元ブログ、sqliteのupdateはlimit出来ない - 技術は熱いうちに打て!

開発環境
SQLite 3.8.8.3

※ただし、自分でソースコードをビルドして入れたものは大丈夫だそうです。

1.0 The SQLite Amalgamation

すごいつまづきました。

select, insert, create table等は出来るのにupdateが出来ない。
みてみたらsqlite3_prepare_v2()がSQLITE_OKを返していない。

問題となったクエリは以下です。

update user set name = 'daiki1003' where id = 1 limit 1;

※たとえ、idを絞っていてもdeleteやupdateを叩く際は必ずlimitを付ける癖を付けています。

amalgamationはlimitをサポートしていない

文法的にどこも間違っていないのに突っぱねるsqlite3_prepare_v2()。
調べてみたらamalgamationだとlimitは出来ないそうです。

SQL As Understood By SQLite

SQLITE_ENABLE_UPDATE_DELETE_LIMIT オプションが必要だそう。

誰かのお役に立てば。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?