開發(fā)中常用的簡(jiǎn)單SQL語(yǔ)句

創(chuàng)建表: create table if not exists 表名 (字段名1, 字段名2...);
create table if not exists t_student (id integer primary key autoincrement, name text not null, age integer)

增加數(shù)據(jù): insert into 表名 (字段名1, 字段名2, ...) values(字段1的值, 字段2的值, ...);
insert into t_student (name,age) values (@"Jack",@17);

根據(jù)條件刪除數(shù)據(jù): delete from 表名 where 條件;
delete from t_student where name = @"Jack";

刪除表中所有的數(shù)據(jù): delete from 表名
delete from t_student

根據(jù)條件更改某個(gè)數(shù)據(jù): update 表名 set 字段1 = '值1', 字段2 = '值2' where 字段1 = '字段1的當(dāng)前值'
update t_student set name = 'lily', age = '16' where name = 'Jack'

根據(jù)條件查找: select * from 表名 where 字段1 = '字段1的值'
select * from t_student where age = '16'

查找所有數(shù)據(jù): select * from 表名
select * from t_student

刪除表: drop table 表名
drop table t_student

排序查找: select * from 表名 order by 字段
select from t_student order by age asc (升序,默認(rèn)) select from t_student order by age desc (降序)

限制: select * from 表名 limit 值1, 值2
select * from t_student limit 5, 10 (跳過5個(gè),一共取10個(gè)數(shù)據(jù))

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 50個(gè)常用的sql語(yǔ)句Student(S#,Sname,Sage,Ssex) 學(xué)生表Course(C#,Cname...
    哈哈海閱讀 1,339評(píng)論 0 7
  • 一、SQL語(yǔ)句如果要在程序運(yùn)行過程中操作數(shù)據(jù)庫(kù)中的數(shù)據(jù),那得先學(xué)會(huì)使用SQL語(yǔ)句1.什么是SQLSQL(struc...
    命運(yùn)建筑師fly閱讀 2,852評(píng)論 0 2
  • 今天進(jìn)行了小考試,考試中一開始特著急,出錯(cuò)了好幾次,后來(lái)及時(shí)發(fā)現(xiàn)了,覺得正常對(duì)待就可以,以后就越來(lái)越穩(wěn)了,燈的功能...
    龐爽閱讀 116評(píng)論 0 0
  • 你曾有過什么樣的浪漫,在你過往的某個(gè)時(shí)光里一度成為你快樂的源泉? 08至09年,因?yàn)橐粋€(gè)姑娘在全年級(jí)收集中性筆筆芯...
    端木不帥閱讀 383評(píng)論 0 2

友情鏈接更多精彩內(nèi)容