iOS-資料庫sqlite的使用

來源:互聯網
上載者:User

標籤:sqlite3   關閉   關閉資料庫   條件陳述式   style   nbsp   取出   track   null   

.資料庫的增刪查改的方法

sqlite3_exec(db, [sql UTF8String], NULL, NULL, &erro);

資料庫的使用

       步驟:01.匯入架構<sqlite3.h>

        02.建立資料庫(sqlite3_exec)並開啟資料庫(sqlite3_open())

        03.建立表,加入欄位(sqlite3_exec)

                04.實現資料庫的增,刪,改,查詢操作(sqlite3_exec)

05.關閉資料庫(sqlite3_close())

        查詢操作步驟:

                  01.校正語句是否合法:sqlite3_prepare_v2

                  02.綁定要查詢的資料:sqlite3_bind_text

                  03.迴圈尋找內容(依據行):sqlite3_step

                   04.取出這一行裡面的資料(依據相應的類):sqlite3_column_text

.SQL語句使用的公式

    建表:

        01. creat table 表名(欄位名 欄位類型,欄位名 欄位類型)

        02. creat table if not exist 表名(欄位名欄位類型,欄位名 欄位類型)

        列如:creat table if not exist user(id integer,name text,phone text);

    插入:insert into 表名(欄位,欄位)values (‘內容’。‘內容’);

    刪除:delete from 表名 where 欄位 = ‘要刪的內容’;

    改動:update 表名 set 欄位 = ‘改動的內容‘ where欄位 = ‘改動前的內容‘

    set後面是新的資料,where後面是之前的資料

    查詢:

        01.select *from 表名 查詢全部的欄位(*表示全部)。

        02.select 欄位1。欄位2....from表名;

        如:select *from user;

 

 

    條件陳述式:

    where 欄位 = 內容;

    where 欄位 is 內容;//相當=

    where 欄位 != 內容。

    where 欄位 is not 內容;

    where 欄位 > 內容;

    where 欄位 > 內容 and 欄位>內容;&& where欄位 > 內容 or 欄位 > 內容



iOS-資料庫sqlite的使用

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.