sqlite³£¼ûÎÊÌâ
(1) ÈçºÎ½¨Á¢×Ô¶¯Ôö³¤×Ö¶Î?
¼ò¶Ì»Ø´ð£ºÉùÃ÷Ϊ INTEGER PRIMARY KEY µÄÁн«»á×Ô¶¯Ôö³¤¡£
³¤Ò»µãµÄ´ð°¸£º Èç¹ûÄãÉùÃ÷±íµÄÒ»ÁÐΪ INTEGER PRIMARY KEY£¬ÄÇô£¬ ÿµ±ÄãÔÚ¸ÃÁÐÉϲåÈëÒ»NULLֵʱ£¬ NULL×Ô¶¯±»×ª»»ÎªÒ»¸ö±È¸ÃÁÐÖÐ×î´óÖµ´ó1µÄÒ»¸öÕûÊý£¬Èç¹û±íÊǿյģ¬ ½«»áÊÇ1¡£ (Èç¹ûÊÇ×î´ó¿ÉÄܵÄÖ÷¼ü 9223372036854775807£¬ÄǸö£¬½«¼üÖµ½«ÊÇËæ»úδʹÓõÄÊý¡££© È磬ÓÐÏÂÁÐ±í£º
CREATE TABLE t1(
a INTEGER PRIMARY KEY,
b INTEGER
);
ÔڸñíÉÏ£¬ÏÂÁÐÓï¾ä
INSERT INTO t1 VALUES(NULL,123);
ÔÚÂß¼ÉϵȼÛÓÚ£º
INSERT INTO t1 VALUES((SELECT max(a) from t1)+1,123);
ÓÐÒ»¸öеÄAPI½Ð×ö sqlite3_last_insert_rowid()£¬ Ëü½«·µ»Ø×î½ü²åÈëµÄÕûÊýÖµ¡£
×¢Òâ¸ÃÕûÊý»á±È±íÖиÃÁÐÉϵIJåÈë֮ǰµÄ×î´óÖµ´ó1¡£ ¸Ã¼üÖµÔÚµ±Ç°µÄ±íÖÐÊÇΨһµÄ¡£µ«ÓпÉÄÜÓëÒÑ´Ó±íÖÐɾ³ýµÄÖµÖصþ¡£ ÒªÏ뽨Á¢ÔÚÕû¸ö±íµÄÉúÃüÖÜÆÚÖÐΨһµÄ¼üÖµ£¬ÐèÒªÔÚ INTEGER PRIMARY KEY ÉÏÔö¼ÓAUTOINCREMENTÉùÃ÷¡£ÄÇô£¬ÐµļüÖµ½«»á±È¸Ã±íÖÐÔøÄÜ´æÔÚ¹ýµÄ×î´óÖµ´ó1¡£ Èç¹û×î´ó¿ÉÄܵÄÕûÊýÖµÔÚÊý¾Ý±íÖÐÔø¾´æÔÚ¹ý£¬INSERT½«»áʧ°Ü£¬ ²¢·µ»ØSQLITE_FULL´íÎó´úÂë¡£
--------------------------------------------------------------------------------------------------------------------------------------------------
(2)SQLite3Ö§³ÖºÎÖÖÊý¾ÝÀàÐÍ£¿
NULL
INTEGER
REAL
TEXT
BLOB
µ«Êµ¼ÊÉÏ£¬sqlite3Ò²½ÓÊÜÈçϵÄÊý¾ÝÀàÐÍ£º
smallint 16 λԪµÄÕûÊý¡£
interger 32 λԪµÄÕûÊý¡£
decimal(p,s) p ¾«È·ÖµºÍ s ´óСµÄÊ®½øλÕûÊý£¬¾«È·ÖµpÊÇָȫ²¿Óм¸¸öÊý(digits)´óСֵ £¬sÊÇָСÊýµãááÓм¸Î»Êý¡£Èç¹ûûÓÐÌرðÖ¸¶¨£¬Ôòϵͳ»áÉèΪ p=5; s=0 ¡£
float 32λԪµÄʵÊý¡£
double 64λԪµÄʵÊý¡£
char(n) n ³¤¶ÈµÄ×Ö´®£¬n²»Äܳ¬¹ý 254¡£
varchar(n) ³¤¶È²»¹Ì¶¨ÇÒÆä×î´ó³¤¶ÈΪ n µÄ×Ö´®£¬n²»Äܳ¬¹ý 4000¡£
graphic(n) ºÍ char(n) Ò»Ñù£¬²»¹ýÆ䵥λÊÇÁ½¸ö×ÖÔª double-bytes£¬ n²»Äܳ¬¹ý127¡£ Õâ¸öÐÎ̬ÊÇΪÁËÖ§Ô®Á½¸ö×ÖÔª³¤¶ÈµÄ×ÖÌ壬ÀýÈçÖÐÎÄ×Ö¡£
vargraphic(n) ¿É±ä³¤¶ÈÇÒÆä×î´ó³¤¶ÈΪ n µÄË«×ÖÔª×Ö´®£¬n²»Äܳ¬¹ý 2000¡£
date °üº¬ÁË Äê·Ý¡¢Ô·ݡ¢ÈÕÆÚ¡£
time °üº¬ÁË Ð¡Ê±¡¢·ÖÖÓ¡¢Ãë¡£
timestamp °üº¬ÁË Äê¡¢Ô¡¢ÈÕ¡¢Ê±¡
Ïà¹ØÎĵµ£º
ÕâÁ½ÌìC/SµÄÏîÄ¿ÖÐÓõ½ÁËsqlite£¬Õâ¸öС¶«Î÷»¹ÕæÊǺÃÓ᣷ÃÎÊËٶȺܿ첻˵£¬Éú³ÉµÄÊý¾Ý¿âÎļþÒ²ºÜС¡£·Ç³£ÊʺÏСÐÍÏîÄ¿µÄÊý¾Ý¿â¡£winceÖÐÇ¿ÁÒ½¨ÒéʹÓá£
²»¹ý½ñÌìÓöµ½Ò»¸öÎÊÌâÈÃÈËÍ·´ó£¬deleteÊý¾ÝµÄʱºòÌáʾno such table¡£
Êý¾Ý¿âÖеıíÃ÷Ã÷´æÔÚ£¬ÔÚÊý¾Ý¿âÖÐÖ´ÐÐdeleteµÄsqlҲûÓÐÎÊÌâ¡£¿´À´²»ÊÇsqlÓï¾äµÄÎÊÌâ¡£
µ«ÊÇÖ ......
ÏÂÔØ´úÂë
È¡µÃÒ»·Ý¶þ½øÖÆ¿½±´, »òÕßÊÇÔ´´úÂë²¢×Ô¼º±àÒëËü. ¹ØÓÚ ÏÂÔØÒ³£¨download£© µÄ¸ü¶àÐÅÏ¢.
´´½¨Ò»¸öÐÂÊý¾Ý¿â
ÔÚ DOS ÃüÁîÐÐÏÂ, ÊäÈë: "sqlite3 test.db". ½«´´½¨Ò»¸öеÄÊý¾Ý¿âÎļþÃû½Ð"test.db". (Äã¿ÉÒÔʹÓò»Í¬µÄÃû×Ö)
ÊäÈë SQL ÃüÁîÔÚÌáʾ·ûÏ´´½¨ºÍдÈëеÄÊý¾Ý.
д³ÌÐòʹÓà SQLite
ÏÂÃæÊÇÒ»¸ö¼òµ¥µ ......
http://www.umgr.com/blog/PostView.aspx?bpId=36294
1. Ö´ÐÐsqlÓï¾ä
int sqlite3_exec(sqlite3*£¬ const char *sql£¬ sqlite3_callbacksql Óï·¨
£¬ void *£¬ char **errmsg );
Õâ¾ÍÊÇÖ´ÐÐÒ»Ìõ sql Óï¾äµÄº¯Êý¡£
µÚ1¸ö²ÎÊý²»ÔÙ˵ÁË£¬ÊÇÇ°Ãæopenº¯ÊýµÃµ½µÄÖ¸Õ롣˵ÁËÊǹؼüÊý¾Ý½á¹¹¡£
µÚ2¸ö²ÎÊýconst char ......
1. SQLite Database Browser ÊÇÒ»¸öSQLiteÊý¾Ý¿â¹ÜÀí¹¤¾ß¡£ÊÇ¿ªÔ´µÄ¡¢Ãâ·ÑµÄ¡£
Home Page
http://sqlitebrowser.sourceforge.net/
Download
http://sourceforge.net/project/showfiles.php?group_id=87946
Wiki
http://en.wikipedia.org/wiki/SQLite_Database_Browser
2.  ......