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(?)";
DbParameter Field1 = cmd.CreateParameter();
cmd.Parameters.Add(Field1);
for (int n = 0; n < 100000; n++)
{
Field1.Value = n + 100000;
cmd.ExecuteNonQuery();
}
dbTrans.Commit();
}
catch
{
dbTrans.RollBack();
}
}
}
}
Ïà¹ØÎĵµ£º
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Ìõ¼Ç¼¿ªÊ¼£¬Íùºó ......
1¡¢SQLite¼ò½é
¡¡¡¡SQLiteµÚÒ»¸öAlpha°æ±¾µ®ÉúÓÚ2000Äê5ÔÂ. ÖÁ½ñÒѾÓÐ9¸öÄêÍ·ÁË. SQLiteÒ²ÓÀ´ÁËÒ»¸ö°æ±¾ SQLite 3ÒѾ·¢²¼.
¡¡¡¡SQLiteÊÇÒ»¿îÇáÐ͵ÄÊý¾Ý¿â£¬ÊÇ×ñÊØACIDµÄ¹ØÁªÊ½Êý¾Ý¿â¹ÜÀíϵͳ£¬ËüµÄÉè¼ÆÄ¿±êÊÇǶÈëʽµÄ£¬¶øÇÒÄ¿Ç°ÒѾÔںܶàǶÈëʽ²úÆ·ÖÐʹÓÃÁËËü£¬ËüÕ¼ÓÃ×ÊÔ´·Ç³£µÄµÍ£¬ÔÚǶÈëʽÉ豸ÖУ¬¿ÉÄÜÖ»ÐèÒª¼¸°ÙKµ ......
ÔÙ˵ÔÚlinuxϽ¨Á¢.a ºÍµãso
µ½ÍøÕ¾ÏÂÔØ sqlite-amalgamation-3.6.22.tar.gz Õâ¸ö°ü£¬·´ÕýÎÒÏÂÁËsqlite3-3.6.22.bin.gz½âѹºó±àÒë²»ÁË¡£
½âѹ£¬ÔËÐÐ
# ./configure --host=armv5l-linux --prefix=/opt/sqlite3/arm --enable-threadsafe.
......
/*=================================
.* The Standard include file.
.*
.*===============================*/
#include <stdio.h>
#include <stdlib.h>
/*=================================
.*
.* The extend include file.
.*
.*===============================*/
#include "sqlit ......
Ç°Á½ÆªÈÕÖ¾ÎÒÒѾ×ܽáÁ˱¾µØÊý¾Ý´æ´¢µÄÇ°Á½ÖÖ£ºÎļþºÍÅäÖÃÏî¡£»¹Ê£ÏÂ×îºóÒ»ÖÖÊý¾Ý¿â´æ´¢——SQLite¡£
Ò»¡¢SQLite¼ò½é
ÔÚAndroidƽ̨ÉÏ£¬¼¯³ÉÁËÒ»¸öǶÈëʽ¹ØϵÐÍÊý¾Ý¿â—SQLite£¬SQLite3Ö§³Ö NULL¡¢INTEGER¡¢REAL£¨¸¡µãÊý×Ö£©¡¢TEXT(×Ö·û´®Îı¾)ºÍBLOB(¶þ½øÖƶÔÏó)Êý¾ÝÀàÐÍ£¬ËäÈ»ËüÖ§³ÖµÄÀàÐÍËäȻֻÓÐÎåÖÖ ......