Sqlite????????
???????????? ???????[ 2016/8/23 9:43:02 ] ????????????? SQLite
????1.Sqlite????????
????SQLite?????Acid??????????????????????C/S???????????????????У?????????????????????????????????????д???????????????????????????????
????SQLite????????????????????Alter table???????????У????????????顣
??????????
????1.??????????譎???
????2.??????
????3.?????2T
????4.??С??3???д???
????5.???
???????????????????????????????????檔
?????????????????????????SQL???????????????????????
???????????????????????????????????庬?塣
????????????????????????????sQL?????????????????е????
??????????棺
?????????????????????????????У?
????B/B+?????????????鼯??????????vm????????????????????
????????????????????????????????????????????????????????棬????????????????ACID???
????2.SQLite??SQL
????SQLite ??SQL????SQL92???????????Щ???????????
????1.?????????
????????sqlite3+ ?????????????sqlite3 school.db
??????????
???????????????????????У??????С??????????????????????
????SQL??create [temp | temporary] table ???? ??????? ???????? ?????????? ???????? ???……??;
???????sql???????β??temp ???????????????????????????????????????????????
????SQLite?????????????????5??????????????????????????Щ?????
???????????? ??? Null ?????? INTEGER ???? REAL ?????? TEXT ?????????????????utf-8????utf-16.utf-16le BLOB ???????飬??????????????
????SQLite???????????????????κ??е????????δ???????????κ???????????????????????ж???????????
????SQLite???boolean????????????????
???????????????????ο???????£?
????http://www.cnblogs.com/bpasser/archive/2011/11/02/2233455.html
???????????
?????????????????洢????е???????????????κ??ж?????洢?κ?????????????? ????Щ?洢??????????????????????????????????
??????????????????е????????????????5?????????????????????????????????
?????????????????????
???????????? Affinity???? Interger INT TINYINT SMALLINT MEDIUMINT BIGINT UNSIGNED BIG INT INT2 INT8 INTEGER CHARACTER(20) VARCHAR(255) VARYING CHARACTER(255) NCHAR(55) NATIVECHAR(70) NVARCHAR(100) TEXT CLOB TEXT BLOB NO DATATYPE NONE REAL DOUBLE DOUBLE PRECISION FLOAT REAL NUMERIC DECIMAL BOOLEAN DATE DATETIME NUMERIC ???
??????????????????????????е??????Щ???????????????????е???????????????????????????????????????
??????????????м???????
?????м?????????????У????????????????????
???????????? SQLite ?г?????????
????NOT NULL ??????????в????? NULL ???
????DEFAULT ?????????????????????????????????
????UNIQUE ????????????е????????????????????????е????????
????PRIMARY Key ???????????????е????/?????
????CHECK ?????CHECK ??????????е???????????????????
?????????classes?????
????CREATE TABLE classes ??
????id INTEGER PRIMARY KEY AUTOINCREMENT??
????mayjor varchar??20??CHECK (length(name)>3)??
????year integer not null ??
????);
???????????
????PRIMARY KEY ?????????????е?????????????????п????ж?? UNIQUE ?У??????????????????????????????????????????????????? ID??
??????????????????????????????????????????rowid??64λ???Σ??????????
??????????
??????????????????????????????????е???????????????????????????????????????????д?????????????????????????????????????????????÷????
????????????????????????????????????Android ??????????????????????
????PRAGMA foreign_keys = ON??
??????????????
????FOREIGN KEY (??????) REFERENCES ???????????У?
????[ON {DELETE | UPDATE } ????????
????[NOT] DEFERRABLE INITIALLY {DEFERRED | IMMEDIATE}]
????????б??????????????????????????????
?????????б???????????????????????л??????????????У???????????У?deferable ???????????
???????磺CREATE TABLE students ??
????id INTEGER PRIMARY KEY AUTOINCREMENT??
????name varchar??20??CHECK (length(name)>3)??
????tel_no varchar(11) not null unique??
????cls_id integer not null??
????FORENIGN KEY (cls_id) PREFERENCES classes(id)??
????UNIQUE(name??tel_no)
????);
??????students?в??????????cls_id???????classes???д?????????????????????????id??????students?????
??????????????????????
????NO ACTION :????????
????RESTRICT????????????????
????SET NULL????????null
????SET DEFAULT?????????
????CASCADE:???????????????????????????е??????????
????????????
????????insert into ???? ??????б??values (??ζ?????)
?????磺insert into classes (id ?? majyor??year) values( 1?? “chuanbo “??”2015”);
??????????б?????????????????????????б??
????????????
????insert into ????(????б?) ???????
??????????stu ??create table stu (id integer primary key ??name varchar(20)??tel_no varchar(11) not null??cls_id integer not null);
??????students??????????stu??insert into stu select * from students;?????????Щ??ν??в???
??????????????create table stu as select * from stdents; as?????
????????????????stu?????????????????????????????????????????????????????????????????????±??????????
??????????? Select ???
???????????????????????????????в????????
????SQLite??????????????????????????в?????
?????????????????????????????????????γ????????
????==select ???????????????????==??select?????????
????select [distinct] ????б? from ???б? where ???? group by ????б? order by ????б? limit ??????offset ???λ??
??????from???????????????????????????????
????from ?ж?????????????????????????select ???????б???????????????????磺
????select classes.mayjor ?? students.name from classes ??students where classes.id =2;
??????κ??????
??????????????????????????Σ????????????????SQL??????????????????????????????????????SQL??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11