国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

SQLite終端相關命令

2019-11-14 19:48:06
字體:
來源:轉載
供稿:網友

SQLite ALL

Last login: Fri Dec  5 09:52:08 on ttys002

BeSilent:~ qianfeng$ sqlite3 data.db

SQLite version 3.7.13 2012-07-17 17:46:21

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite> create table USER(id,name,score);//創建表

sqlite> .table

USER

sqlite> create table if not exists USER(id,name,score);//創建表

sqlite> .table

USER
sqlite> drop table USER;//刪除表

sqlite> create table if not exists USER(id,name,score);

sqlite> .table

USER
sqlite> insert into USER values(1,"普京",90);//插入

sqlite> insert into USER values(2,"奧巴馬",50);

sqlite> select *from USER

   ...> ;

1|普京|90

2|奧巴馬|50

 

sqlite> insert into USER values(3,"神雕",100);

sqlite> insert into USER values(4,"楊過",150);

sqlite> insert into USER values(5,"王麗坤",90);
sqlite> select * from USER;//查詢

1|普京|90

2|奧巴馬|50

3|神雕|100

4|楊過|150

5|王麗坤|90

sqlite> insert into USER values(6,"陳喬恩",90);

sqlite> select * from USER;

1|普京|90

2|奧巴馬|50

3|神雕|100

4|楊過|150

5|王麗坤|90

6|陳喬恩|90
sqlite> delete from USER where id=2;//刪除元素

sqlite> select * from USER;

1|普京|90

3|神雕|100

4|楊過|150

5|王麗坤|90

6|陳喬恩|90

sqlite> update USER set id=2 where id=6;//修改

sqlite> select *from USER;

1|普京|90

3|神雕|100

4|楊過|150

5|王麗坤|90

2|陳喬恩|90

sqlite> update USER set score= 89 where id=2;//修改

sqlite> select *from USER;

1|普京|90

3|神雕|100

4|楊過|150

5|王麗坤|90

2|陳喬恩|89
sqlite> select name,score from USER;//查詢 name,score

普京|90

神雕|100

楊過|150

王麗坤|90

陳喬恩|89
sqlite> select * from USER limit3;//查詢前三項

1|普京|90

3|神雕|100

4|楊過|150

5|王麗坤|90

2|陳喬恩|89
sqlite> select * from USER order by id;//通過id 升序查詢

1|普京|90

2|陳喬恩|89

3|神雕|100

4|楊過|150

5|王麗坤|90

sqlite> select *from USER;

1|普京|90

3|神雕|100

4|楊過|150

5|王麗坤|90

2|陳喬恩|89

sqlite> select * from USER order by score desc;//降序查詢

4|楊過|150

3|神雕|100

1|普京|90

5|王麗坤|90

2|陳喬恩|89

sqlite> select * from USER order by name limit 3;

1|普京|90

4|楊過|150

5|王麗坤|90

sqlite> select count(*)from USER;//查詢count(*)

5

sqlite> select sum(score) from USER;//查詢sum(score)

519

 
sqlite> select avg(score) from USER;//查詢avg(score)

103.8

 
sqlite> create table if not exists WUGONG(wid integer PRimary key autoincrement,name,uid);//wid integer primary key auto increment,多表,主鍵,外鍵,唯一鍵

sqlite> insert into WUGONG(name,uid) values("葵花",5);

sqlite> insert into WUGONG(name,uid) values("獨孤九劍",4);

sqlite> insert into WUGONG(name,uid) values("降龍十八掌",3);

sqlite> insert into WUGONG(name,uid) values("黯然銷魂掌",2);

sqlite> insert into WUGONG(name,uid) values("一陽指",1);

sqlite> select *from USER;

1|普京|90

3|神雕|100

4|楊過|150

5|王麗坤|90

2|陳喬恩|89

sqlite> select USER.id,USER.name,WUGONG.name,USER.score from USER,WUGONG where USER.id=WUGONG.uid;//多表查詢

1|普京|一陽指|90

3|神雕|降龍十八掌|100

4|楊過|獨孤九劍|150

5|王麗坤|葵花|90

2|陳喬恩|黯然銷魂掌|89
sqlite> select USER.id,USER.name,WUGONG.name,USER.score from USER,WUGONG where USER.id=WUGONG.uid order by USER.score;//多表查詢按成績升序(asc)

2|陳喬恩|黯然銷魂掌|89

1|普京|一陽指|90

5|王麗坤|葵花|90

3|神雕|降龍十八掌|100

 

4|楊過|獨孤九劍|150

 
 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 德兴市| 广安市| 义乌市| 惠水县| 青浦区| 中牟县| 福鼎市| 托里县| 锦州市| 商洛市| 萍乡市| 剑阁县| 阿克| 科尔| 石河子市| 教育| 杭锦后旗| 浦江县| 广宗县| 阜南县| 宣城市| 本溪市| 成都市| 金秀| 香格里拉县| 曲靖市| 信丰县| 临沂市| 晋州市| 乐平市| 涟源市| 安庆市| 聂拉木县| 鄂尔多斯市| 松滋市| 利川市| 马公市| 胶州市| 美姑县| 延庆县| 蚌埠市|