ios UI資料庫 sqlite小型資料庫的增、刪、改、查、排序

來源:互聯網
上載者:User

標籤:ui資料庫   sqlite輕量級資料庫的使用   ios   oc   

#import "table.h"


@implementation table


// 1.建立表 每一列之間用‘,‘,如果存在就不建立

create tableif not exists t_class(

                                   class_id integer primary key autoincrement,

                                   class_name varchar,

                                   person_count integerdefault 0)


// 1.1// 刪除表

drop tableif exists t_person


// 2.插入資料(增),因為設定id為自增,所以不輸入直接為1


insert into t_class (class_name,person_count) values(‘class1‘,10)


// 3.刪除資料(刪)

// table裡的全刪  deleta from t_class

// 刪除指定id=5的資料    delete from t_class where class_id=5


// 4.修改資料

name全改成newclassname     update t_class set class_name=‘newclassname‘


 修改某一行的某個資料 update t_class set class_name=‘newclassname‘ where class_id=7


// 5.查詢資料(查)

 查詢所有             select * from"t_class"

 查詢指定一個或者幾個資料                select class_id,person_count from t_class where class_name=‘oldname‘


關鍵字 and or

select class_id,person_count from t_class where class_id=7 and person_count=20

select class_id,person_count from t_class where class_id=7 or person_count=20

select class_id,person_count from t_class where class_id between7 and 20


// in like不需要非要查主鍵

select class_id,person_count from t_class where class_idin(7,9)// 在7和9的

select class_id,person_count from t_class where class_id notin(7,9)//不在7和9的

select class_id,person_count from t_class where class_name like‘new%‘ //以new開頭

select class_id,person_count from t_class where class_name like‘%class‘ // 以new結尾


// 擷取表的資料總數在count(*)後面加名字可以起別名

select count(*) number from t_class// count1是按第一列來統計,一般以主鍵列統計一般寫*就可以


// 擷取最小值

select min(person_count) from t_class


// 擷取最大值

select min(person_count) from t_class


// 擷取平均值

select avg(person_count) from t_class


// 擷取總成績

select sum(person_count) from t_class


// 擷取絕對值

select abs(person_count) from t_class


// 在不修改資料的前提下查詢結果去除前後空格

select trim(class_name) from t_class


// 替換

select replace(class_name,‘c‘,‘o‘) from t_class


// 長度(空格也算長度)

select length(class_name) from t_class


// 日期函數

select date() from t_class

select datetime() from t_class


// 判斷為空白

select * from t_class where class_name is null


// 排序

select * from t_class order by class_id desc(倒序)

select * from t_class order by class_id asc   (正序、asc可省預設正序)


@end



ios UI資料庫 sqlite小型資料庫的增、刪、改、查、排序ios UI資料庫 sqlite小型資料庫的增、刪、改、查、排序ios UI資料庫 sqlite小型資料庫的增、刪、改、查、排序ios UI資料庫 sqlite小型資料庫的增、刪、改、查、排序ios UI資料庫 sqlite小型資料庫的增、刪、改、查、排序ios UI資料庫 sqlite小型資料庫的增、刪、改、查、排序,輕量級資料庫,資料庫都是類似的,弄懂一個其他的也會用了

ios UI資料庫 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.