Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : Sqlite

ǶÈëʽÊý¾Ý¿âµäÐͼ¼Êõ¨DSQLiteºÍBerkeley DBµÄÑо¿

Õª Òª: Óë³£¼ûµÄÊý¾Ý¿âÏà±È£¬Ç¶Èëʽ
Êý
¾Ý¿â¾ßÓÐÌå»ýС¡¢¹¦ÄÜÆ뱸¡¢¿ÉÒÆÖ²ÐÔ¡¢½¡×³ÐÔµÈÌص㣬±¾ÎÄ·ÖÎöºÍ±È½ÏÁ˵äÐ͵ÄǶÈëʽÊý¾Ý¿âSQLiteºÍBerkeley DB¡£Ê×ÏÈ´ÓÌåϵ½á¹¹¡¢×Óϵͳ
¼äµ÷ÓùØϵ¡¢ÈÎÎñÖ´Ðйý³ÌµÈ½Ç¶È¶ÔSQLiteºÍBerkeley DB½øÐÐÁËÏêϸ·ÖÎö£¬È»ºóÖصã´ÓÊý¾ÝÀàÐÍ¡¢´æ´¢·½Ê½¡¢Ä£Ê½¡¢Êý¾Ý¿âÒýÇæºÍ´íÎó´¦Àí¼°¼Ó
Ãܹ¦Äܵȷ½ÃæÌÖÂÛÁËSQLiteºÍBerkeley DBµÄÒìͬµã£¬×îºóÁоÙÁËÒ»¸ö»ùÓÚARM—LinuxµÄSQLiteÓ¦ÓÃʵÀý¡£
¹Ø¼ü´Ê: SQLite¡¢Berkeley DB¡¢SQL¡¢ÐéÄâÊý¾Ý¿âÒýÇ棨VDBE£©
ÒýÑÔ
Ëæ׿ÆËã
»ú¼¼ÊõÓëÆäËüѧ¿Æ¼äµÄ²»¶Ï½»ÈÚ¡¢Éø͸£¬Êý¾Ý¿âÓ¦Óõķ¶Î§
¸ü¼ÓÉîÈëºÍ¾ßÌå¡£ÄÇЩ½öÊÊÓÃÓÚPC»ú£¬Ìå»ýÅÓ´ó¡¢ÑÓʱ½Ï³¤µÄÊý¾Ý¿â¼¼ÊõÒѲ»ÄÜÂú×ãÕë¶ÔÐÔ½ÏÇ¿µÄǶÈëʽϵͳ¿ª·¢µÄÐèÇó¡£SOLiteºÍBerkeley
DBÊÇÄ¿Ç°Ó¦ÓýϹ㷺¡¢¼¼Êõ½ÏÎȶ¨µÄÁ½ÖÖǶÈëʽÊý¾Ý¿â¡£È»¶ø£¬¹úÄÚ¶ÔǶÈëʽÊý¾Ý¿âµÄÑо¿Æð²½½ÏÍí£¬»¹Ã»ÄÜÒýÆð¸ü¶àÈ˵ĹØ×¢¡£¸ü¶àÈËÊìϤÄÇЩ»ùÓÚC/S»òB
/S½á¹¹µÄ¹ØϵÐÍÊý¾Ý¿âÀ´ÊµÏÖÊý¾ÝµÄ´æ´¢¡¢¼ìË÷µÈ¹¦ÄÜ¡£È»¶ø£¬ÔÚǶÈëʽϵͳÖУ¬ÓÉÓÚÈíÓ²¼þ×ÊÔ´ÓÐÏÞ£¬²»¿ÉÄÜ°²×°ÅÓ´óµÄÊý¾Ý¿â·þÎñÆ÷£¬¶øÓû§µÄÐèÇó¿ÉÄÜÓÉÒ»
¸ö¼òµ¥µÄ»ùÓÚ´ÅÅÌÎļþµÄÊý¾Ý¿âÏ ......

SQLite²»Ö§³ÖµÄSQLÓï·¨×ܽá


1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾­³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄÇ°Ê®Ìõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0Ìõ¼Ç¼¿ªÊ¼£¬ÍùºóÒ»¹²¶ÁÈ¡10Ìõ
2 ´´½¨ÊÓͼ£¨Create View£©
SQLiteÔÚ´´½¨¶à±íÊÓͼµÄʱºòÓÐÒ»¸öBUG£¬ÎÊÌâÈçÏ£º
CREATE VIEW watch_single AS SELECT
DISTINCTwatch_item.[watchid],watch_item.[itemid] from watch_item;
ÉÏÃæÕâÌõSQLÓï¾äÖ´Ðкó»áÏÔʾ³É¹¦£¬µ«ÊÇʵ¼ÊÉϳýÁË
SELECT COUNT(*) from [watch_single ] WHERE watch_ single.watchid = 1;
ÄÜÖ´ÐÐÖ®ÍâÊÇÎÞ·¨Ö´ÐÐÆäËûÈκÎÓï¾äµÄ¡£ÆäÔ­ÒòÔÚÓÚ½¨Á¢ÊÓͼµÄʱºòÖ¸¶¨ÁË×Ö¶ÎËùÔڵıíÃû£¬¶øSQLite²¢²»ÄÜÕýÈ·µØʶ±ðËü¡£ËùÒÔÉÏÃæµÄ´´½¨Óï¾äÒª¸ÄΪ£º
CREATE VIEW watch_single AS SELECT DISTINCT [watchid],[itemid] from
watch_item;
µ«ÊÇËæÖ®¶øÀ´µÄÎÊÌâÊÇÈç¹ûÊǶà±íµÄÊÓͼ£¬ÇÒ±í¼äÓÐÖØÃû×ֶεÄʱºò¸ÃÔõô°ì£¿
3 COUNT£¨DISTINCT column£©
SQLiteÔÚÖ´ÐÐÈçÏÂÓï¾äµÄʱºò»á±¨´í£º
SELECT COUNT(DISTINCT watchid ......

SQLite²»Ö§³ÖµÄSQLÓï·¨×ܽá


1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾­³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄÇ°Ê®Ìõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0Ìõ¼Ç¼¿ªÊ¼£¬ÍùºóÒ»¹²¶ÁÈ¡10Ìõ
2 ´´½¨ÊÓͼ£¨Create View£©
SQLiteÔÚ´´½¨¶à±íÊÓͼµÄʱºòÓÐÒ»¸öBUG£¬ÎÊÌâÈçÏ£º
CREATE VIEW watch_single AS SELECT
DISTINCTwatch_item.[watchid],watch_item.[itemid] from watch_item;
ÉÏÃæÕâÌõSQLÓï¾äÖ´Ðкó»áÏÔʾ³É¹¦£¬µ«ÊÇʵ¼ÊÉϳýÁË
SELECT COUNT(*) from [watch_single ] WHERE watch_ single.watchid = 1;
ÄÜÖ´ÐÐÖ®ÍâÊÇÎÞ·¨Ö´ÐÐÆäËûÈκÎÓï¾äµÄ¡£ÆäÔ­ÒòÔÚÓÚ½¨Á¢ÊÓͼµÄʱºòÖ¸¶¨ÁË×Ö¶ÎËùÔڵıíÃû£¬¶øSQLite²¢²»ÄÜÕýÈ·µØʶ±ðËü¡£ËùÒÔÉÏÃæµÄ´´½¨Óï¾äÒª¸ÄΪ£º
CREATE VIEW watch_single AS SELECT DISTINCT [watchid],[itemid] from
watch_item;
µ«ÊÇËæÖ®¶øÀ´µÄÎÊÌâÊÇÈç¹ûÊǶà±íµÄÊÓͼ£¬ÇÒ±í¼äÓÐÖØÃû×ֶεÄʱºò¸ÃÔõô°ì£¿
3 COUNT£¨DISTINCT column£©
SQLiteÔÚÖ´ÐÐÈçÏÂÓï¾äµÄʱºò»á±¨´í£º
SELECT COUNT(DISTINCT watchid ......

SQLITE SQLÓï¾äµÄ×¢Òâ


1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾­³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄÇ°Ê®Ìõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0Ìõ¼Ç¼¿ªÊ¼£¬ÍùºóÒ»¹²¶ÁÈ¡10Ìõ
2 ´´½¨ÊÓͼ£¨Create View£©
SQLiteÔÚ´´½¨¶à±íÊÓͼµÄʱºòÓÐÒ»¸öBUG£¬ÎÊÌâÈçÏ£º
CREATE VIEW watch_single AS SELECT DISTINCTwatch_item.[watchid],watch_item.[itemid] from watch_item;
ÉÏÃæÕâÌõSQLÓï¾äÖ´Ðкó»áÏÔʾ³É¹¦£¬µ«ÊÇʵ¼ÊÉϳýÁË
SELECT COUNT(*) from [watch_single ] WHERE watch_ single.watchid = 1;
ÄÜÖ´ÐÐÖ®ÍâÊÇÎÞ·¨Ö´ÐÐÆäËûÈκÎÓï¾äµÄ¡£ÆäÔ­ÒòÔÚÓÚ½¨Á¢ÊÓͼµÄʱºòÖ¸¶¨ÁË×Ö¶ÎËùÔڵıíÃû£¬¶øSQLite²¢²»ÄÜÕýÈ·µØʶ±ðËü¡£ËùÒÔÉÏÃæµÄ´´½¨Óï¾äÒª¸ÄΪ£º
CREATE VIEW watch_single AS SELECT DISTINCT [watchid],[itemid] from watch_item;
µ«ÊÇËæÖ®¶øÀ´µÄÎÊÌâÊÇÈç¹ûÊǶà±íµÄÊÓͼ£¬ÇÒ±í¼äÓÐÖØÃû×ֶεÄʱºò¸ÃÔõô°ì£¿
3 COUNT£¨DISTINCT column£©
SQLiteÔÚÖ´ÐÐÈçÏÂÓï¾äµÄʱºò»á±¨´í£º
SELECT COUNT(DISTINCT watchid) fr ......

SQLITE SQLÓï¾äµÄ×¢Òâ


1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾­³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄÇ°Ê®Ìõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0Ìõ¼Ç¼¿ªÊ¼£¬ÍùºóÒ»¹²¶ÁÈ¡10Ìõ
2 ´´½¨ÊÓͼ£¨Create View£©
SQLiteÔÚ´´½¨¶à±íÊÓͼµÄʱºòÓÐÒ»¸öBUG£¬ÎÊÌâÈçÏ£º
CREATE VIEW watch_single AS SELECT DISTINCTwatch_item.[watchid],watch_item.[itemid] from watch_item;
ÉÏÃæÕâÌõSQLÓï¾äÖ´Ðкó»áÏÔʾ³É¹¦£¬µ«ÊÇʵ¼ÊÉϳýÁË
SELECT COUNT(*) from [watch_single ] WHERE watch_ single.watchid = 1;
ÄÜÖ´ÐÐÖ®ÍâÊÇÎÞ·¨Ö´ÐÐÆäËûÈκÎÓï¾äµÄ¡£ÆäÔ­ÒòÔÚÓÚ½¨Á¢ÊÓͼµÄʱºòÖ¸¶¨ÁË×Ö¶ÎËùÔڵıíÃû£¬¶øSQLite²¢²»ÄÜÕýÈ·µØʶ±ðËü¡£ËùÒÔÉÏÃæµÄ´´½¨Óï¾äÒª¸ÄΪ£º
CREATE VIEW watch_single AS SELECT DISTINCT [watchid],[itemid] from watch_item;
µ«ÊÇËæÖ®¶øÀ´µÄÎÊÌâÊÇÈç¹ûÊǶà±íµÄÊÓͼ£¬ÇÒ±í¼äÓÐÖØÃû×ֶεÄʱºò¸ÃÔõô°ì£¿
3 COUNT£¨DISTINCT column£©
SQLiteÔÚÖ´ÐÐÈçÏÂÓï¾äµÄʱºò»á±¨´í£º
SELECT COUNT(DISTINCT watchid) fr ......

ÓÃvs2008±àÒë³ösqlite dllºÍlib (ͼ½â)

1£º´ÓsqliteµÄ¹ÙÍøÉÏÏÂÔØÔ´Âë http://www.sqlite.org/download.html
2£º´ò¿ªvs2008¹¤³Ìн¨Ò»¸ö¿ÕµÄdll¹¤³Ì¡£
3£º°Ñsqlite3.h,sqlite3.cpp,sqlite3.def·Ö±ð¼ÓÈëµ½head file ºÍsource fileÏ¡£
4£º±àÒë³ÌÐò¡£ ÕâʱֻÄܵõ½sqlite3.dllÎļþ¡£
5£º´ò¿ªvs2008×Ô´øµÄÃüÁîÐУº Çе½sqlite3.defËùÔÚµÄĿ¼¡£
 
6£ºÔËÐÐÃüÁlib /def:sqlite3.def.ºó¿ÉµÃµ½sqlite3.libÎļþ¡£
 
Íê³É¡£ ......

Android£¨Èý£©Êý¾Ý´æ´¢Ö®ÈýSQLiteǶÈëʽÊý¾Ý¿â

Ç°Á½ÆªÈÕÖ¾ÎÒÒѾ­×ܽáÁ˱¾µØÊý¾Ý´æ´¢µÄÇ°Á½ÖÖ£ºÎļþºÍÅäÖÃÏî¡£»¹Ê£ÏÂ×îºóÒ»ÖÖÊý¾Ý¿â´æ´¢——SQLite¡£
Ò»¡¢SQLite¼ò½é
ÔÚAndroidƽ̨ÉÏ£¬¼¯³ÉÁËÒ»¸öǶÈëʽ¹ØϵÐÍÊý¾Ý¿â—SQLite£¬SQLite3Ö§³Ö NULL¡¢INTEGER¡¢REAL£¨¸¡µãÊý×Ö£©¡¢TEXT(×Ö·û´®Îı¾)ºÍBLOB(¶þ½øÖƶÔÏó)Êý¾ÝÀàÐÍ£¬ËäÈ»ËüÖ§³ÖµÄÀàÐÍËäȻֻÓÐÎåÖÖ£¬µ«Êµ¼ÊÉÏsqlite3Ò²½ÓÊÜvarchar(n)¡¢char(n)¡¢decimal(p,s) µÈÊý¾ÝÀàÐÍ£¬Ö»²»¹ýÔÚÔËËã»ò±£´æʱ»áת³É¶ÔÓ¦µÄÎåÖÖÊý¾ÝÀàÐÍ¡£ SQLite×î´óµÄÌصãÊÇÄã¿ÉÒÔ±£´æÈκÎÀàÐ͵ÄÊý¾Ýµ½ÈκÎ×Ö¶ÎÖУ¬ÎÞÂÛÕâÁÐÉùÃ÷µÄÊý¾ÝÀàÐÍÊÇʲô¡£ÀýÈ磺¿ÉÒÔÔÚInteger×Ö¶ÎÖдæ·Å×Ö·û´®£¬»òÕßÔÚ²¼¶ûÐÍ×Ö¶ÎÖдæ·Å¸¡µãÊý£¬»òÕßÔÚ×Ö·ûÐÍ×Ö¶ÎÖдæ·ÅÈÕÆÚÐÍÖµ¡£ µ«ÓÐÒ»ÖÖÇé¿öÀýÍ⣺¶¨ÒåΪINTEGER PRIMARY KEYµÄ×Ö¶ÎÖ»ÄÜ´æ´¢64λÕûÊý£¬ µ±ÏòÕâÖÖ×Ö¶ÎÖб£´æ³ýÕûÊýÒÔÍâµÄÊý¾Ýʱ£¬½«»á²úÉú´íÎó¡£ÁíÍ⣬ SQLite ÔÚ½âÎöCREATE TABLE Óï¾äʱ£¬»áºöÂÔ CREATE TABLE Óï¾äÖиúÔÚ×Ö¶ÎÃûºóÃæµÄÊý¾ÝÀàÐÍÐÅÏ¢¡£
¶þ¡¢SQLiteµÄCURD
AndroidÌṩÁËÒ»¸öÃûΪSQLiteDatabaseµÄÀ࣬¸ÃÀà·â×°ÁËһЩ²Ù×÷Êý¾Ý¿âµÄAPI£¬Ê¹ÓøÃÀà¿ÉÒÔÍê³É¶ÔÊý¾Ý½øÐÐÌí¼Ó(Create)¡¢²éѯ(Retrieve)¡¢¸üÐÂ(Update)ºÍɾ³ý(Delete)²Ù×÷£¨Õ ......

SQLiteÆô¶¯ÊÂÎï

ÊÂÎñ£¨DbTransaction£©£º
SQLite ȱʡΪÿ¸ö²Ù×÷Æô¶¯Ò»¸öÊÂÎñ£¬ËùÒÔ³ÉÅú²åÈëµÄʱºò£¬Æô¶¯ÊÂÎñ£¬±È²»Æô¶¯ÊÂÎñ¿ìn±¶¡£
ÔÚûÆô¶¯ÊÂÎñ֮ǰÍùSqliteÊý¾Ý¿âÀï²åÈë1000¶àÌõÊý¾ÝµÄÇé¿ö,½á¹ûÿ´Î¶¼ÐèÒªÒ»Á½·ÖÖÓ²ÅÄÜÍê³É.
¶øÔÚÆô¶¯ÊÂÎïÒÔºóËùÐèÒªµÄʱ¼äÖ±½Ó±ä³É²»µ½2Ãë!Ô­À´sqlite»¨Á½·ÖÖÓÊÇÓÉÓÚExecuteNonQuery·½·¨Ö´ÐÐʱ×Ô¼ºÌá½»Á˸üÐÂÊÂÎñ£¬Ä¬ÈÏÖ´ÐиüвÙ×÷ÊÇ»á×Ô¶¯Ìá½»ÊÂÎñµÄ,Ò²¾ÍÊÇ˵ĬÈÏÇé¿öÏÂÒ»ÌõSQLÓï¾ä¾ÍÊÇÒ»¸öÊÂÎñ,Èç¹û²»Ã÷°×¿ÉÒÔÈ¥¿´ÊÂÎñµÄ¸ôÀ뼶±ð¡£
¸ü¸ÄºóµÄ´úÂë°ÑËùÓеĸüÐÂSQL·ÅÔÚÒ»¸öÊÂÎñÖУ¬Ö»ÓÐÖ´Ðе½Commit·½·¨Ê±²ÅÌá½»ÊÂÎñ¡£
ÓëÊý¾Ý¿âͨÐŵÄÄÚÈÝÁ½´ÎÍê³ÉµÄ£¬µ«¾ÉµÄ·½·¨½øÐÐÁË100000´ÎͨÐÅ£¬
¶øз½·¨Ö»½øÐÐÒ»´ÎͨÐÅ,ʱ¼äµÄ²î±ð¾Í³öÀ´ÁË¡£¡£
public static void InsertManyData(DbConnection conn)
{
using (DbTransaction dbTrans = conn.BeginTransaction())
{
using (DbCommand cmd = conn.CreateCommand())
{
try
{
cmd.CommandText = "INSERT INTO Test(MyValue) VALUES(?)";
......
×ܼǼÊý:155; ×ÜÒ³Êý:26; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [3] [4] [5] [6] 7 [8] [9] [10] [11] [12]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ