SQLiteÈëÃÅÓë·ÖÎö(Ò»)
ÒòΪÏîÄ¿ÐèÒª£¬ÐèҪʹÓÃsqlite£¬ÔÚcsdnµÄblogÖУ¬·¢ÏÖÁË´ËÎÄÕ£¬
ÒÔÏÂϵÁоùÕª×Ô£ºhttp://www.cnblogs.com/hustcat/ лл£¡
1¡¢SQLite½éÉÜ
×Ô¼¸Ê®ÄêÇ°³öÏÖµÄÉÌÒµÓ¦ÓóÌÐòÒÔÀ´£¬Êý¾Ý¿â¾Í³ÉΪÈí¼þÓ¦ÓóÌÐòµÄÖ÷Òª×é³É²¿·Ö¡£ÕýÓëÊý¾Ý¿â¹ÜÀíϵͳ·Ç³£¹Ø¼üÒ»Ñù£¬ËüÃÇÒ²±äµÃ·Ç³£ÅӴ󣬲¢Õ¼ÓÃÁËÏ൱¶àµÄϵͳ×ÊÔ´£¬Ôö¼ÓÁ˹ÜÀíµÄ¸´ÔÓÐÔ¡£Ëæ×ÅÈí¼þÓ¦ÓóÌÐòÖð½¥Ä£¿éÄ£¿é»¯£¬Ò»ÖÖÐÂÐÍÊý¾Ý¿â»á±È´óÐ͸´ÔӵĴ«Í³Êý¾Ý¿â¹ÜÀíϵͳ¸üÊÊÓ¦¡£Ç¶ÈëʽÊý¾Ý¿âÖ±½ÓÔÚÓ¦ÓóÌÐò½ø³ÌÖÐÔËÐУ¬ÌṩÁËÁãÅäÖã¨zero-configuration£©ÔËÐÐģʽ£¬²¢ÇÒ×ÊÔ´Õ¼Ó÷dz£ÉÙ¡£
SQLiteÊÇÒ»¸ö¿ªÔ´µÄǶÈëʽ¹ØϵÊý¾Ý¿â£¬ËüÔÚ2000ÄêÓÉD. Richard Hipp·¢²¼£¬ËüµÄ¼õÉÙÓ¦ÓóÌÐò¹ÜÀíÊý¾ÝµÄ¿ªÏú£¬SQLite¿ÉÒÆÖ²ÐԺ㬺ÜÈÝÒ×ʹÓ㬺ÜС£¬¸ßЧ¶øÇÒ¿É¿¿¡£
SQLiteǶÈ뵽ʹÓÃËüµÄÓ¦ÓóÌÐòÖУ¬ËüÃǹ²ÓÃÏàͬµÄ½ø³Ì¿Õ¼ä£¬¶ø²»Êǵ¥¶ÀµÄÒ»¸ö½ø³Ì¡£´ÓÍⲿ¿´£¬Ëü²¢²»ÏñÒ»¸öRDBMS£¬µ«ÔÚ½ø³ÌÄÚ²¿£¬ËüÈ´ÊÇÍêÕûµÄ£¬×Ô°üº¬µÄÊý¾Ý¿âÒýÇæ¡£
ǶÈëʽÊý¾Ý¿âµÄÒ»´óºÃ´¦¾ÍÊÇÔÚÄãµÄ³ÌÐòÄÚ²¿²»ÐèÒªÍøÂçÅäÖã¬Ò²²»ÐèÒª¹ÜÀí¡£ÒòΪ¿Í»§¶ËºÍ·þÎñÆ÷ÔÚͬһ½ø³Ì¿Õ¼äÔËÐС£SQLite µÄÊý¾Ý¿âȨÏÞÖ»ÒÀÀµÓÚÎļþϵͳ£¬Ã»ÓÐÓû§ÕÊ»§µÄ¸ÅÄî¡£SQLite ÓÐÊý¾Ý¿â¼¶Ëø¶¨£¬Ã»ÓÐÍøÂç·þÎñÆ÷¡£ËüÐèÒªµÄÄڴ棬ÆäËü¿ªÏúºÜС£¬ÊʺÏÓÃÓÚǶÈëʽÉ豸¡£ÄãÐèÒª×öµÄ½ö½öÊÇ°ÑËüÕýÈ·µÄ±àÒëµ½ÄãµÄ³ÌÐò¡£
2¡¢¼Ü¹¹(architecture)
SQLite²ÉÓÃÁËÄ£¿éµÄÉè¼Æ£¬ËüÓÉÈý¸ö×Óϵͳ£¬°üÀ¨8¸ö¶ÀÁ¢µÄÄ£¿é¹¹³É¡£
2.1¡¢½Ó¿Ú(Interface)
½Ó¿ÚÓÉSQLite C API×é³É£¬Ò²¾ÍÊÇ˵²»¹ÜÊdzÌÐò¡¢½Å±¾ÓïÑÔ»¹ÊÇ¿âÎļþ£¬×îÖÕ¶¼ÊÇͨ¹ýËüÓëSQLite½»»¥µÄ(ÎÒÃÇͨ³£Óõý϶àµÄODBC/JDBC×îºóÒ²»áת»¯ÎªÏàÓ¦C APIµÄµ÷ÓÃ)¡£
2.2¡¢±àÒëÆ÷(Compiler)
ÔÚ±àÒëÆ÷ÖУ¬·Ö´ÊÆ÷£¨Tokenizer£©ºÍ·ÖÎöÆ÷(Parser)¶ÔSQL½øÐÐÓï·¨¼ì²é£¬È»ºó°ÑËüת»¯Îªµ×²ãÄܸü·½±ã´¦ÀíµÄ·Ö²ãµÄÊý¾Ý½á¹¹---Óï·¨Ê÷£¬È»ºó°ÑÓï·¨Ê÷´«¸ø´úÂëÉú³ÉÆ÷(code generator)½øÐд¦Àí¡£¶ø´úÂëÉú³ÉÆ÷¸ù¾ÝËüÉú³ÉÒ»ÖÖÕë¶ÔSQLiteµÄ»ã±à´úÂ룬×îºóÓÉÐéÄâ»ú(Virtual Machine)Ö´ÐС£
2.3¡¢ÐéÄâ»ú(Virtual Machine)
¼Ü¹¹ÖÐ×îºËÐĵIJ¿·ÖÊÇÐéÄâ»ú£¬»òÕß½Ð×öÐéÄâÊý¾Ý¿âÒýÇæ(Virtual Database Engine,VDBE)¡£ËüºÍJavaÐéÄâ»úÏàËÆ£¬½âÊÍÖ´ÐÐ×Ö½Ú´úÂë¡£VDBEµÄ×Ö½Ú´úÂëÓÉ128¸ö²Ù×÷Âë(opcodes)¹¹³É£¬ËüÃÇÖ÷Òª¼¯ÖÐÔÚÊý¾Ý¿â²Ù×÷¡£ËüµÄÿһÌõÖ¸ÁÓÃÀ´Íê³ÉÌض¨µÄÊý¾Ý¿â²Ù×÷(±ÈÈç´ò¿ªÒ»¸ö±íµÄÓαê)»òÕßΪÕâЩ²Ù×÷Õ»¿Õ¼äµÄ×¼±¸(±ÈÈçѹÈë²ÎÊý)¡£×ÜÖ®£¬ËùÓÐ
Ïà¹ØÎĵµ£º
Ç°Ò»Õó×Ö×öÏîÄ¿(ǶÈëʽlinux)£¬ÓÉÓÚÒª±£´æ´óÁ¿µÄÊý¾Ý£¬¶øÇÒ×Ҫ±£´æ30ÌìµÄʱ¼ä¡£±¾À´´òËã±£´æµ½ÎļþÖУ¬Ã¿´ÎÆô¶¯Ó¦ÓóÌÐòµÄʱºòÖØнâÎöÒ»±é£¬¿ÉÊǵ±Êý¾ÝÁ¿ºÜ´óµÄʱºò£¬¾Í³öÏÖЧÂʵÄÎÊÌâÁË¡£ËùÒÔ×îºó»¹ÊÇ·ÅÆúÁËʹÓÃÎļþµÄ´òË㣬¾ö¶¨Ê¹ÓÃÊý¾Ý¿â´æÈ¡Êý¾Ý¡£
linuxϵÄÊý¾Ý¿âÒ²ºÜ¶à£¬ÓпªÔ´µÄ£¬Ò²ÓÐÊշѵġ£¶ÔÓÚÎÒÃÇÀ´Ëµ£¬¿Ï ......
SQLiteÊý¾Ý¿âÁ¬½Ó·½Ê½
SQLite.NET
Type: .NET Framework Class Library
Usage: System.Data.SQLite.SQLiteConnection
Basic
Data Source=filename;Version=3;
Version 2 is not supported by this class library.
Using UTF16
Data Source=filename;Version=3;UseUTF16 ......
sqlite3: Ò»¸öSQLiteÊý¾Ý¿âµÄÃüÁîÐнӿÚ
ÒëÕß×¢
ÔÎĵØÖ·£ºhttp://www.sqlite.org/sqlite.html
SQLite¿â°üº¬Ò»¸öÃû×Ö½Ð×ösqlite3 µÄÃüÁîÐÐ,Ëü¿ÉÒÔÈÃÓû§ÊÖ¹¤ÊäÈë²¢Ö´ÐÐÃæÏòSQLiteÊý¾Ý¿âµÄSQLÃüÁî¡£±¾ÎĵµÌṩһ¸öÑùʹÓÃsqlite3µÄ¼òҪ˵Ã÷¡£
¿ªÊ¼
Æô¶¯sqlite3 ³ÌÐò£¬½ö½öÐèÒªÇÃÈ ......
ÓÃÁËADO.NET 2.0 SQLite Data Provider ÕâÑù¿ÉÒÔÖ±½ÓÀûÓÃËüÀ´´´½¨Ò»¸ö¼ÓÃܵÄsqliteÊý¾Ý¿â¡£
ÓйØc#´úÂëÈçÏ£º
1¡¢´´½¨¿ÕµÄsqliteÊý¾Ý¿â¡£
//Êý¾Ý¿âÃûµÄºó׺Äã¿ÉÒÔÖ±½ÓÖ¸¶¨£¬ÉõÖÁûÓкó׺¶¼¿ÉÒÔ
//·½·¨Ò»£º´´½¨Ò»¸ö¿ÕsqliteÊý¾Ý¿â£¬ÓÃIOµÄ·½Ê½
FileStream fs = File.Create(“c:\\test.db“);
//·½·¨¶þ£ºÓ ......
ÔÚ AndroidÖУ¬¶ÔÓÚÊý¾ÝµÄ´æÖü£¬Óм¸ÖÖ·½Ê½£¬ÓÐÎļþ·½Ê½£¬ÓÐÎļþʽÊý¾Ý¿â·½Ê½,Android×Ô´øÁËÒ»¸öSQLiteÊý¾Ý¿â£¬×öǶÈ뿪·¢µÄÈ˶ÔÕâ¸ö¿çƽ̨µÄ±¾µØÎļþÊý¾Ý¿âÒ»¶¨²»»áÄ°Éú£¬ÔÚAndroid¶ÔÓÚÊý¾ÝµÄ·ÃÎÊ£¬Ìá³öÁËеķ½Ê½£¬ContentProvider·½Ê½£¬ÀàËÆÓÚMSµÄ ContentProvider·½Ê½µÄ£¬OLEDB£¬¼°ODBCͳһµÄÊý¾Ý·½Ê½¡£
ÎÒÃÇÊ×ÏÈÀ´¿´¿ ......