Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLite DatabaseÅжÏÊÇ·ñ´æÔÚ¡¢Ð½¨¡¢É¾³ý.....

¡¡Android SQLite Database±¾´òËã·â×°SQLiteµÄ£¬µ«ÊÇ£¬·¢ÏÖʵ¼ÊÉÏAndroidÒѾ­·â×°ÁËÒ»²ã£¬ÓÈÆäÊÇÊý¾ÝµÄÔö¡¢É¾¡¢²é¡¢¸ÄÉÏ£¬¸üÊÇÈç´Ë£¬ËùÒÔ£¬ÎÒºóÀ´Ö»·â×°ÁËÒ»¸öÁ¬½Ó²ã£¬¸ºÔð´ò¿ª¡¢½¨Á¢Êý¾Ý¿â£¬²¢·µ»ØÒ»¸öSQLiteµÄʵÀýÓÃÀ´Íê³ÉÔö¡¢É¾¡¢²å¡¢¸ÄµÈ²Ù×÷¡£
//----------- DBHelper -------------
package utility.db;
import java.io.FileNotFoundException;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
public class DBHelper
{
private SQLiteDatabase db = null;
private Context ctx = null;
public DBHelper( Context ctx )
{
this.ctx = ctx;
}
/**
* ÅжÏÊý¾Ý¿âÊÇ·ñ´æÔÚ
*
* @param dbName
* Êý¾Ý¿âÃû³Æ
* @return true´æÔÚ false²»´æÔÚ
*/
public boolean exist( String dbName )
{
Log.log("called fun : exist()");
boolean flag = false;
try
{
db = ctx.openDatabase(dbName, null);
Log.log("database/"+dbName+" exist");
flag = true;
}
catch (FileNotFoundException e)
{
flag = false;
Log.log("database/"+dbName+" not exist");
}
finally
{
if (db != null)
db.close();
db = null;
}
return flag;
}
/**
* ´ò¿ªÊý¾Ý¿â
*
* @param dbName
* Êý¾Ý¿âÃû³Æ
* @return true ´ò¿ª³É¹¦ false´ò¿ªÊ§°Ü
*/
public boolean openDatabase( String dbName , boolean created )
{
return openDatabase(dbName, null, created);
}
/**
* ´ò¿ªÊý¾Ý¿â
*
* @param dbName
* Êý¾Ý¿âÃû³Æ
* @param factory
* @return true ´ò¿ª³É¹¦ false´ò¿ªÊ§°Ü
*/
public boolean openDatabase( String dbName , CursorFactory factory ,
boolean created )
{
Log.log("called fun : openDatabase()");
Log.log("called fun : if not exist then created "+dbName+" ? : "+created);
boolean flag = false;
if(exist(dbName))
{
try
{
db = ctx.openDatabase(dbName, factory);
Log.log("database/"+dbName+" is opened");
flag = true;
}
catch (FileNotFoundException e)
{
Log.log("database/"+dbName+" is not opened");
flag = false;
}
}
else
{
if(created)
{
flag = createDatabase(dbName, 1, 0, factory);
}
else
{
flag = false;
}
}
return flag;
}


Ïà¹ØÎĵµ£º

sqliteºÍpdo mysqlµÄÊý¾Ý¿â²Ù×÷

½ñÌìµÄѧϰÄÚÈÝÊÇsqliteºÍPDO mysql¡£
ÓÃ×Ô¼ºµÄ»°ËµËµÁ½¸ö¶«Î÷°É£º
sqliteËãÊÇÒ»ÖÖ²»ÏµÍ³µÄÊý¾Ý¿â´æ´¢·½Ê½£¬ËüµÄ´æ·Å¸ñʽÊÇÒ»¸ö.dbºó׺µÄÎļþ£¬ÔÚphpÖÐËü´æ·ÅÔÚµ±Ç°µÄĿ¼Ï£¬Ã²ËƲ»ÓÃÓû§ÃûÃÜÂ룬°²È«ÐԽϵͣ¬È´±È½Ï·½±ã¡£PHP5ÖÐ×Ô´øµÄһЩϵͳº¯Êý£¬¶¼ÊÇÒÔsqlite_¿ªÍ·µÄ¡£
PDOÈ«³ÆPHP Data Object£¬¹ËÃû˼Òå¾ÍÊÇPHPµÄÒ ......

×ܽá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Ìõ¼Ç¼¿ªÊ¼£¬Íùºó ......

windowsÏÂsqlite°²×°Ê¹ÓúÍÐÔÄÜÓÅ»¯¼°ÉèÖÃ

Ô­ÎÄÁ´½Ó£ºhttp://edu.codepub.com/2008/1231/805.php
windowsÏÂsqlite°²×°Ê¹ÓúÍÐÔÄÜÓÅ»¯¼°ÉèÖÃ
      sqliteÊÇǶÈëʽSQLÊý¾Ý¿âÒýÇæSQLite£¨SQLite Embeddable SQL Database Engine£©µÄÒ»¸öÀ©Õ¹¡£SQLiteÊÇÒ»¸öʵÏÖǶÈëʽSQLÊý¾Ý¿âÒýÇæСÐÍCÓïÑԿ⣨C library£©£¬ÊµÏÖÁ˶ÀÁ¢µÄ£¬¿ÉǶÈëµÄ£¬ÁãÅäÖ ......

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Ìõ¼Ç¼¿ªÊ¼£¬Íùºó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ