Where is SQLite?
SQLite is available on the Android device itself. The executable is in the /system/bin directory of the device. You can see that this directory contains the shell commands like ls, ps, etc., as well as sqlite3, dalvikvm, and dexdump utilities.
Code Listing 1. Contents of system/bin
# pwd
pwd
/system/bin
# ls -l
ls -l
-rwxr-xr-x root root 196 2008-02-29 01:09 am
-rwxr-xr-x root root 2342 2008-02-29 01:09 dumpstate
-rwxr-xr-x root root 208 2008-02-29 01:09 input
-rwxr-xr-x root root 212 2008-02-29 01:09 monkey
-rwxr-xr-x root root 196 2008-02-29 01:09 pm
…
lrwxr-xr-x root root 2008-02-29 01:16 mount -> toolbox
lrwxr-xr-x root root 2008-02-29 01:16 notify -> toolbox
-rwxr-xr-x root root 28032 2008-02-29 01:16 dexdump
-rwxr-xr-x root root 7100 2008-02-29 01:16 dumpsys
-rwxr-xr-x root root 7904 2008-02-29 01:16 mem_profiler
-rwxr-xr-x root root 6480 2008-02-29 01:16 service
-rwxr-xr-x root root 4320 2008-02-29 01:16 rild ......
SQL-92ÌØÐÔ·½Ãæ
ÕýÈçÇ°ÃæÌáµ½µÄ£¬SQLite²»Ö§³ÖSQL-92µÄÔںܶàÆóÒµÊý¾Ý¿âϵͳÖпÉÓõÄһЩÌØÐÔ¡£
È磺
Íâ¼üÔ¼Êø£¨¿É½âÎöµÄ£¬µ«·ÇÇ¿ÖÆ£©
ºÜ¶àALTER TABLEÌØÐÔ
һЩTRIGGERÏà¹ØµÄÌØÐÔ
RIGHTºÍFULL OUTER JOIN
¸üÐÂÒ»¸öVIEW
GRANTºÍREVOKE
Äã¿ÉÒÔÔÚSQLiteµÄÖ÷Ò³ÉÏ»ñÈ¡×îÐÂÐÅÏ¢¡£
http://www.sqlite.org/omitted.html
http://www.sqlite.org/cvstrac/wiki?p=UnsupportedSql
µÍ²¢·¢²Ù×÷
SQLiteÖ»Ö§³ÖƽÃæÊÂÎñ£»ËüûÓÐǶÌ׺ÍÓª¾ÈµãÄÜÁ¦¡£Ç¶Ì×Òâζ×ÅÔÚÒ»¸öÊÂÎñÖпÉÒÔÓÐ×ÓÊÂÎñµÄÄÜÁ¦¡£Óª¾ÈµãÔÊÐíÒ»¸öÊÂÎñ·µ»Øµ½Ç°ÃæÒѾµ½´ïµÄ״̬¡£ËüûÓÐÄÜÁ¦È·±£¸ß²ã´ÎÊÂÎñµÄ²¢·¢¡£ËüÔÊÐíÔÚµ¥¸öµÄÊý¾Ý¿âÎļþÉ϶à¸ö²¢·¢µÄ¶ÁÊÂÎñ£¬µ«ÊÇÖ»ÄÜÓÐÒ»¸öÅÅËûµÄдÊÂÎñ¡£Õâ¸ö¾ÖÏÞÐÔÒâζ×ÅÈç¹ûÓÐÊÂÎñÔÚ¶ÁÊý¾Ý¿âÎļþµÄÒ»²¿·Ö£¬ËùÓÐÆäËûµÄÊÂÎñ½«±»½ûֹд¸ÃÎļþµÄÈκÎÒ»²¿·Ö¡£ÀàËƵģ¬Èç¹ûÓÐÊÂÎñÔÚдÊý¾Ý¿âÎļþµÄÒ»²¿·Ö£¬ËùÓÐÆäËûÊÂÎñ½«±»½ûÖ¹¶Á»òÕßд¸ÃÎļþµÄÈκÎÒ»²¿·Ö¡£
Ó¦ÓÃÏÞÖÆ
ÒòΪËüÊÂÎñ´¦ÀíµÄÓÐÏÞ²¢·¢£¬SQLiteÖ»Éó¤´¦ÀíСÐ͵ÄÊÂÎñ¡£ÔںܶàÇé¿öÏ£¬Õâ²»ÊÇÎÊÌ⡣ÿ¸öÓ¦ÓÃѸËÙµÄÍê³ÉËüµÄÊý¾Ý¿â¹¤×÷È»ºó¼ÌÐøÇ°½ø£¬Òò´ËûÓÐÒ»¸öÊÂÎñ»á³ÖÓÐÊý¾Ý¿â³¬¹ý¶àÉÙºÁÃë¡£µ«ÊÇÔÚһЩӦÓÃÖУ¬ÌرðÊÇдÈëÃܼ¯µÄ ......
Ç°Ðò£º... 1
Ò»¡¢ °æ±¾... 1
¶þ¡¢ »ù±¾±àÒë... 2
Èý¡¢ SQLITE²Ù×÷ÈëÃÅ... 2
£¨1£© »ù±¾Á÷³Ì... 2
£¨2£© SQLÓï¾ä²Ù×÷... 4
£¨3£© ²Ù×÷¶þ½øÖÆ... 8
£¨4£© ÊÂÎñ´¦Àí... 10
ËÄ¡¢ ¸øÊý¾Ý¿â¼ÓÃÜ... 10
Îå¡¢ ºó¼Ç... 25
Ç°Ðò£º
Sqlite3 µÄÈ·ºÜºÃÓá£Ð¡ÇÉ¡¢Ëٶȿ졣µ«ÊÇÒòΪ·Ç΢ÈíµÄ²úÆ·£¬°ïÖúÎĵµ×ܾõµÃ²»¹»¡£ÕâЩÌìÔÙ´ÎÑо¿Ëü£¬ÓÖÓÐһЩÊÕ»ñ£¬ÕâÀï°ÑÎÒ¶Ô sqlite3 µÄÑо¿ÁгöÀ´£¬ÒÔ±¸Íü¼Ç¡£
ÕâÀïҪעÃ÷£¬ÎÒÊÇÒ»¸ö¿çƽ̨רעÕߣ¬²¢²»Ï²»¶Ö»Óà windows ƽ̨¡£ÎÒÒÔÇ°µÄ¹¤×÷¾ÍÊÇΪ unix ƽ̨д´úÂë¡£ÏÂÃæÎÒËùдµÄ¶«Î÷£¬ËäȻûÓÐÑéÖ¤£¬µ«ÊÇÎÒÒѾ¡Á¿²»Ê¹ÓÃÈκΠwindows µÄ¶«Î÷£¬Ö»Ê¹Óñê×¼ C »ò±ê×¼C++¡£µ«ÊÇ£¬ÎÒûÓг¢ÊÔ¹ýÔÚ±ðµÄϵͳ¡¢±ðµÄ±àÒëÆ÷ϱàÒ룬Òò´ËÏÂÃæµÄÐðÊöÈç¹û²»ÕýÈ·£¬ÔòÁô´ýÒÔºóÐ޸ġ£
ÏÂÃæÎҵĴúÂëÈÔÈ»Óà VC ±àд£¬ÒòΪÎÒ¾õµÃVCÊÇÒ»¸öºÜ²»´íµÄIDE£¬¿ÉÒÔ¼Ó¿ì´úÂë±àдËٶȣ¨ÀýÈçÅäºÏ Vassist £©¡£ÏÂÃæÎÒËù˵µÄ±àÒë»·¾³£¬ÊÇVC2003¡£Èç¹û¶ÁÕß¾õµÃ×Ô¼ºÏ°¹ßÓÚ unix ÏÂÓà vi ±àд´úÂëËٶȽϿ죬¿ÉÒÔ²»ÓùÜÎÒµÄ˵Ã÷£¬Ö»ÐèÒª·ûºÏ×Ô¼ºÏ°¹ß¼´¿É£¬ÒòΪÎÒÓõÄÊDZê×¼ C »ò C++ ¡£²»»á¸øÈκÎÈË´øÀ´²»±ã¡£
Ò»¡¢ °æ±¾
´Ó www.sqlite.org ÍøÕ¾¿ÉÏÂÔص½×îÐ嵀 sq ......
£¨2£© SQLÓï¾ä²Ù×÷
±¾½Ú½éÉÜÈçºÎÓÃsqlite Ö´Ðбê×¼ sql Óï·¨¡£
i.1 Ö´ÐÐsqlÓï¾ä
int sqlite3_exec(sqlite3*, const char *sql, sqlite3_callback, void *, char **errmsg );
Õâ¾ÍÊÇÖ´ÐÐÒ»Ìõ sql Óï¾äµÄº¯Êý¡£
µÚ1¸ö²ÎÊý²»ÔÙ˵ÁË£¬ÊÇÇ°Ãæopenº¯ÊýµÃµ½µÄÖ¸Õ롣˵ÁËÊǹؼüÊý¾Ý½á¹¹¡£
µÚ2¸ö²ÎÊýconst char *sql ÊÇÒ»Ìõ sql Óï¾ä£¬ÒÔ\0½áβ¡£
µÚ3¸ö²ÎÊýsqlite3_callback Êǻص÷£¬µ±ÕâÌõÓï¾äÖ´ÐÐÖ®ºó£¬sqlite3»áÈ¥µ÷ÓÃÄãÌṩµÄÕâ¸öº¯Êý¡££¨Ê²Ã´Êǻص÷º¯Êý£¬×Ô¼ºÕÒ±ðµÄ×ÊÁÏѧϰ£©
µÚ4¸ö²ÎÊývoid * ÊÇÄãËùÌṩµÄÖ¸Õ룬Äã¿ÉÒÔ´«µÝÈκÎÒ»¸öÖ¸Õë²ÎÊýµ½ÕâÀÕâ¸ö²ÎÊý×îÖջᴫµ½»Øµ÷º¯ÊýÀïÃ棬Èç¹û²»ÐèÒª´«µÝÖ¸Õë¸ø»Øµ÷º¯Êý£¬¿ÉÒÔÌîNULL¡£µÈÏÂÎÒÃÇÔÙ¿´»Øµ÷º¯ÊýµÄд·¨£¬ÒÔ¼°Õâ¸ö²ÎÊýµÄʹÓá£
µÚ5¸ö²ÎÊýchar ** errmsg ÊÇ´íÎóÐÅÏ¢¡£×¢ÒâÊÇÖ¸ÕëµÄÖ¸Õë¡£sqlite3ÀïÃæÓкܶà¹Ì¶¨µÄ´íÎóÐÅÏ¢¡£Ö´ÐÐ sqlite3_exec Ö®ºó£¬Ö´ÐÐʧ°Üʱ¿ÉÒÔ²éÔÄÕâ¸öÖ¸Õ루ֱ½Ó printf(“%s\n”,errmsg)£©µÃµ½Ò»´®×Ö·û´®ÐÅÏ¢£¬Õ ......
£¨4£© ÊÂÎñ´¦Àí
sqlite ÊÇÖ§³ÖÊÂÎñ´¦ÀíµÄ¡£Èç¹ûÄãÖªµÀÄãҪͬ²½É¾³ýºÜ¶àÊý¾Ý£¬²»·Â°ÑËüÃÇ×ö³ÉÒ»¸öͳһµÄÊÂÎñ¡£
ͨ³£Ò»´Î sqlite3_exec ¾ÍÊÇÒ»´ÎÊÂÎñ£¬Èç¹ûÄãҪɾ³ý1ÍòÌõÊý¾Ý£¬sqlite¾Í×öÁË1Íò´Î£º¿ªÊ¼ÐÂÊÂÎñ->ɾ³ýÒ»ÌõÊý¾Ý->Ìá½»ÊÂÎñ->¿ªÊ¼ÐÂÊÂÎñ->… µÄ¹ý³Ì¡£Õâ¸ö²Ù×÷ÊǺÜÂýµÄ¡£ÒòΪʱ¼ä¶¼»¨ÔÚÁË¿ªÊ¼ÊÂÎñ¡¢Ìá½»ÊÂÎñÉÏ¡£
Äã¿ÉÒÔ°ÑÕâЩͬÀà²Ù×÷×ö³ÉÒ»¸öÊÂÎñ£¬ÕâÑùÈç¹û²Ù×÷´íÎ󣬻¹Äܹ»»Ø¹öÊÂÎñ¡£
ÊÂÎñµÄ²Ù×÷ûÓÐÌرðµÄ½Ó¿Úº¯Êý£¬Ëü¾ÍÊÇÒ»¸öÆÕͨµÄ sql Óï¾ä¶øÒÑ£º
·Ö±ðÈçÏ£º
int result;
result = sqlite3_exec( db, "begin transaction", 0, 0, &zErrorMsg ); //¿ªÊ¼Ò»¸öÊÂÎñ
result = sqlite3_exec( db, "commit transaction", 0, 0, &zErrorMsg ); //Ìá½»ÊÂÎñ
result = sqlite3_exec( db, "rollback transaction", 0, 0, &zErrorMsg ); //»Ø¹öÊÂÎñ
Ò»¡¢ ¸øÊý¾Ý¿â¼ÓÃÜ
Ç°ÃæËù˵µÄÄÚÈÝÍøÉÏÒѾÓкܶà×ÊÁÏ£¬ËäÈ»±È½ÏÁãÉ¢£¬µ«ÊÇ»¨µãʱ¼äÒ²»¹ÊÇ¿ÉÒÔÕÒµ½µÄ¡£ÏÖÔÚҪ˵µÄÕâ¸ö——Êý¾Ý¿â¼ÓÃÜ ......
¡ïÈçºÎȨºâ£¿
¡¡¡¡µ±ÄãÔÚȨºâij¸ö³¡ºÏÊÇ·ñÓ¦¸ÃʹÓÃSQLiteʱ£¬£¨ÔÚ¼¼Êõ²ãÃ棩ÖÁÉÙÒª¿¼ÂÇÈçϼ¸µã£º
¡¡¡¡¡óÄÜ·ñ·¢»ÓSQLiteµÄijЩÌس¤£¿
¡¡¡¡¡óÊÇ·ñ»¹ÓÐÆäËüµÄÌæ´ú·½°¸£¿
¡¡¡¡¡óÊÇ·ñÓÐɶDZÔڵļ¼Êõ·çÏÕ£¿
¡¡¡¡ÏëÇå³þÉÏÊöÎÊÌâÖ®ºó£¬ÔÙ×ö³ö¾ö²ß¡£
¡¡¡¡¡ïSQLiteµÄÌصã
¡¡¡¡¹ØÓÚSQLiteµÄÌس¤£¬ÔÚÉϴεÄÌû×ÓÖÐÒѾ½éÉܹýÁË¡£¿¼Âǵ½Ä³Ð©Í¬Ñ§±È½Ï½¡Íü£¬ÔÛÔٻعËһϣº
¡¡¡¡¡óÎļþÐÍÊý¾Ý¿â£¬ÇÒÖ»Óе¥Ò»Êý¾ÝÎļþ
¡¡¡¡¡óÇáÁ¿¼¶
¡¡¡¡¡óÂÌÉ«£¨²»ÒÀÀµÆäËüÈí¼þ¿â£©
¡¡¡¡¡ó¿çƽ̨£¨°üÀ¨ÒýÇæºÍÊý¾ÝÎļþ£©
¡¡¡¡¡óÖ§³ÖÄÚ´æÊý¾Ý¿â
¡¡¡¡¡óÖ§³Ö½Ï´óµÄÊý¾ÝÎļþ£¨TB¼¶±ð£©
¡¡¡¡¡ï¿ÉÄܵÄÌæ´ú·½°¸
¡¡¡¡¸Õ²Å˵ÁË£¬È¨ºâSQLiteµÄʹÓÃÐèÒª¿¼ÂÇÆäËüµÄÌæ´ú·½°¸£¬ËùÒÔ°³¼òµ¥½éÉÜһϺÍSQLiteÓÃ;Ïà½üµÄÆäËü¼¸ÖÖ¼¼ÊõÊֶΡ£ºóÃæ½²Ó¦Óó¡¾°µÄʱºò£¬»á½áºÏÕ⼸¸öÌæ´ú·½°¸À´×÷¶Ô±È¡£
¡¡¡¡¡óAccessÊý¾Ý¿â
¡¡¡¡AccessÊý¾Ý¿âÒ²ÊÇÎļþÐ͵ÄÊý¾Ý¿â£¬Ö§³ÖµÄºÜ¶àSQLÌØÐÔ¶¼ÀàËÆÓÚSQLite¡£×Ô´ÓWindows 2000¿ªÊ¼£¬Windows¾ÍÄÚÖÃÁËAccessµÄÊý¾Ý¿âÒýÇ棨Microsoft Jet Database Engine£©¡£ËùÒÔAccessÊý¾Ý¿âÔÚÉÏÊöϵͳÖÐÒ²ÊÇ¿ÉÒÔ¶ÀÁ¢ÔËÐеģ¨²»ÒÀÀµOffice£©¡£
¡¡¡¡AccessÊý¾Ý¿â×îÖ÷ÒªµÄȱµã¾ÍÊDz»ÄÜ¿çƽ̨¡£ÁíÍâ»¹Ó ......