SQLite相關(guān)

  • SQLite語句
  1. 增加表字段 ALTER TABLE 表名 ADD COLNUM 字段名 字段類型
  2. 刪除表字段 ALTER TABLE 表名 DROP COLNUM 字段名
  3. 修改表字段 ALTER TABLE 表名 RENAME COLNUM 舊字段名 TO 新字段名
  • SQLite的線程安全
    http://stackoverflow.com/questions/6675240/is-sqlite-database-instance-thread-safe
    No, it is not thread-safe by default. You shoud use locking-related SQLiteHelper methods to provide thread safety.
    http://stackoverflow.com/questions/11058098/interprocess-sqlite-thread-safety-on-ios
    I've never used SQLite, but I've spent a decent amount of time reading its docs because I plan on using it in the future (and the docs are interesting). I'd say that thread safety is independent of whether multiple processes can access the same database file at once. SQLite, regardless of what threading mode it is in, will lock the database file, so that multiple processes can read from the database at once but only one can write.
    Thread safety only affects how your process can use SQLite. Without any thread safety, you can only call SQLite functions from one thread. But it should still, say, take an EXCLUSIVE lock before writing, so that other processes can't corrupt the database file. Thread safety just protects data in your process's memory from getting corrupted if you use multiple threads. So I don't think you ever need to worry about what another process (in this case iOS) is doing with an SQLite database.
    Edit: To clarify, any time you write to the database, including a plain INSERT
    /UPDATE
    /DELETE
    , it will automatically take an EXCLUSIVE lock, write to the database, then release the lock. (And it actually takes a SHARED lock, then a RESERVED lock, then a PENDING lock, then an EXCLUSIVE lock before writing.) By default, if the database is already locked (say from another process), then SQLite will return SQLITE_BUSY without waiting. You can call sqlite3_busy_timeout()
    to tell it to wait longer.

  • CoreData的線程安全
    看到知乎上有人說core data是支持多線程的秋秤,但需要thread confinement的方式實(shí)現(xiàn),使用了多線程之后可以最大化的防止阻塞主線程。待實(shí)驗(yàn)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末夫凸,一起剝皮案震驚了整個濱河市就缆,隨后出現(xiàn)的幾起案子荤胁,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 223,002評論 6 519
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件后众,死亡現(xiàn)場離奇詭異,居然都是意外死亡稼锅,警方通過查閱死者的電腦和手機(jī)吼具,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,357評論 3 400
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來矩距,“玉大人拗盒,你說我怎么就攤上這事∽墩” “怎么了陡蝇?”我有些...
    開封第一講書人閱讀 169,787評論 0 365
  • 文/不壞的土叔 我叫張陵,是天一觀的道長哮肚。 經(jīng)常有香客問我登夫,道長,這世上最難降的妖魔是什么允趟? 我笑而不...
    開封第一講書人閱讀 60,237評論 1 300
  • 正文 為了忘掉前任恼策,我火速辦了婚禮,結(jié)果婚禮上潮剪,老公的妹妹穿的比我還像新娘涣楷。我一直安慰自己,他們只是感情好抗碰,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,237評論 6 398
  • 文/花漫 我一把揭開白布狮斗。 她就那樣靜靜地躺著,像睡著了一般弧蝇。 火紅的嫁衣襯著肌膚如雪碳褒。 梳的紋絲不亂的頭發(fā)上折砸,一...
    開封第一講書人閱讀 52,821評論 1 314
  • 那天,我揣著相機(jī)與錄音沙峻,去河邊找鬼睦授。 笑死,一個胖子當(dāng)著我的面吹牛专酗,可吹牛的內(nèi)容都是我干的睹逃。 我是一名探鬼主播,決...
    沈念sama閱讀 41,236評論 3 424
  • 文/蒼蘭香墨 我猛地睜開眼祷肯,長吁一口氣:“原來是場噩夢啊……” “哼沉填!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起佑笋,我...
    開封第一講書人閱讀 40,196評論 0 277
  • 序言:老撾萬榮一對情侶失蹤翼闹,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后蒋纬,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體猎荠,經(jīng)...
    沈念sama閱讀 46,716評論 1 320
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,794評論 3 343
  • 正文 我和宋清朗相戀三年蜀备,在試婚紗的時候發(fā)現(xiàn)自己被綠了关摇。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,928評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡碾阁,死狀恐怖输虱,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情脂凶,我是刑警寧澤宪睹,帶...
    沈念sama閱讀 36,583評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站蚕钦,受9級特大地震影響亭病,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜嘶居,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,264評論 3 336
  • 文/蒙蒙 一罪帖、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧邮屁,春花似錦整袁、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,755評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽泞当。三九已至迹蛤,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背盗飒。 一陣腳步聲響...
    開封第一講書人閱讀 33,869評論 1 274
  • 我被黑心中介騙來泰國打工嚷量, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人逆趣。 一個月前我還...
    沈念sama閱讀 49,378評論 3 379
  • 正文 我出身青樓蝶溶,卻偏偏與公主長得像,于是被迫代替她去往敵國和親宣渗。 傳聞我的和親對象是個殘疾皇子抖所,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,937評論 2 361

推薦閱讀更多精彩內(nèi)容