Android SQLITE ¼òµ¥Æð²½
1£º¶¨Òå±íµÄ½á¹¹ºÍÃû×Ö£¬ÎÒʹÓÃÒÔÏ·½·¨£º
public interface Constatnts extends BaseColumns {
public static final String TABLE_NAME = "test";
public static final String TIME = "time";
public static final String TITLE = "title";
}
ÔÚÕâÀÎҼ̳ÐBaseColumnsµÄÄ¿µÄ£¬ÊÇÖ±½Ó¶¨Òå"_ID"×Ö¶Î
2£º¶¨ÒåSQLiteOpenHelper µÄ×ÓÀ࣬À´¶ÔÓ¦Ò»¸öÊý¾Ý¿â£¬ÖØÔرØÐëµÄonCreate ºÍ onUpgrade¡£ÀïÃæÍ¨¹ýexecSQLµ÷ÓÃÊʵ±µÄSQL Óï¾ä¡£
@Override
// Õâ¸öº¯Êý»áÔÚµÚÒ»´ÎÖ´ÐÐÊý¾Ý¿â²Ù×÷µÄʱºò±»µ÷Óõ½¡£
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + TIME
+ " INTEGER," + TITLE + " TEXT NOT NULL);"); //×¢Ò⣬×îºÃÉùÃ÷×Ö¶ÎÀàÐÍ£¬ÒÔÃâ²»±ØÒªµÄÂé·³¡£
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
db.execSQL("DROP TABLE IF EXITS "+ TABLE_NAME);
onCreate(db);
}
3£ºÊ¹ÓøÃÊý¾Ý¿â¡£
mydatabase = new Databasehelp(this);
²åÈëÊý¾Ý£º
SQLiteDatabase db = mydatabase.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(TIME, System.currentTimeMillis());
values.put(TITLE, string);
db.insertOrThrow(TABLE_NAME, null, values);
²éѯÊý¾Ý£º
SQLiteDatabase db = mydatabase.getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, { _ID, TIME, TITLE, }, null, null, null,
 
Ïà¹ØÎĵµ£º
[±à¼±¾¶Î
]
SQLite¼ò½é
SQLite
µÚÒ»¸öAlpha°æ±¾µ®ÉúÓÚ2000Äê5ÔÂ. ÖÁ½ñÒѾÓÐ10¸öÄêÍ·ÁË. SQLiteÒ²ÓÀ´ÁËÒ»¸ö°æ±¾ SQLite 3ÒѾ·¢²¼.
¡¡¡¡SQLiteÊÇÒ»¿îÇáÐ͵ÄÊý¾Ý¿â£¬ÊÇ×ñÊØACIDµÄ¹ØÁªÊ½Êý¾Ý¿â¹ÜÀíϵͳ£¬ËüµÄÉè¼ÆÄ¿±êÊÇǶÈë
ʽµÄ£¬¶øÇÒĿǰÒѾÔںܶàǶÈëʽ²úÆ·ÖÐʹÓÃÁËËü£¬ËüÕ¼ÓÃ×ÊÔ´·Ç³£µÄµÍ£¬ÔÚǶÈëʽÉ豸ÖУ¬¿ ......
ÔÚ .NET ÀïÃæÊ¹Óà SQLite£¬ ÎÒÕâÀïʹÓõÄwrapperÊÇ System.Data.SQLite£¬ËüÖ»ÐèÒªÒ»¸ödll,½Ó¿Ú·ûºÏADO.Net 2.0µÄ¶¨Òå,ÐÔÄÜÒ²²»´í,NHibernateÓõÄÒ²ÊÇËü£¬Ä¿Ç°Ö§³ÖADO.NET 3.5ÁË£¬Ö§³Ö¼¯³ÉÔÚ VS2005 ºÍ VS2008ÀïÃæ£¬¶øÇÒÖ§³Öwince£¬ÊǸöÁÁµã
ÒòΪ·ûºÏADO.NETµÄ¹æ·¶£¬ËùÒÔʹÓ÷½Ê½£¬»ù±¾ºÍ SqlClient, OleDbµÈÔÉúµÄÒ»ÖÂ
us ......
Ò»¡¢SQLite¼ò½é
SQLite ÊÇÓÃCÓïÑÔ±àдµÄ¿ªÔ´Êý¾Ý¿â£¬Ö÷ÒªÓÃÓÚǶÈëʽ£¬ÄãÒ²¿ÉÒÔ°ÑËü¼¯³ÉÔÚ×Ô¼ºµÄ×ÀÃæ³ÌÐòÖУ¬Ò²ÓÐÈ˽«ÆäÌæ´úAccess£¬ÓÃ×÷ºǫ́Êý¾Ý¿â¡£
SQLite Ö§³Ö¶àÊýSQL92±ê×¼£¬ÀýÈ磺Ë÷Òý¡¢ÏÞÖÆ¡¢´¥·¢ºÍ²é¿´Ö§³Ö¡£
Ö§³Ö NULL¡¢INTEGER¡¢REAL¡¢TEXT ºÍ BLOB Êý¾ÝÀàÐÍ£¬Ö§³ÖÊÂÎñ¡£
¶þ¡¢ÏÂÔØSQLite
SQLite¿ÉÒÔµ½¹Ù·½Õ ......
sqliteʱ¼äº¯Êý£¨×ª£©
2007Äê12ÔÂ10ÈÕ ÐÇÆÚÒ» 13:33
תÌùÔÒò£º×î½üÉè¼ÆÁËÒ»¸ö¿çÊý¾Ý¿âµÄº¯Êý£¬À´²âÊÔ²âÊÔsqlite¡£
SQLite·ÖÒ³ÏÔʾ£ºSelect * from news order by id
desc Limit 10 Offset 10
ÕâÆªÎÄÕÂÊǸù¾Ý SQLite ¹Ù·½ WIKI ÀïµÄÄÚÈÝ·Ò룬Èç¹ûÓÐʲô·Òë²»µ±µÄµØ·½Ï£Íû´ó¼ÒÖ¸³ö£¬±Ï¾¹ÎÒµÄÓ¢ÎÄˮƽʵÔںܲ SQ ......
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 ......