Ubuntu 12.04下SQLite數(shù)據(jù)庫簡單應(yīng)用
SQLite,是一款輕型的數(shù)據(jù)庫,實現(xiàn)了多數(shù)的SQL-92標(biāo)準(zhǔn),包括事務(wù),就是代表原子性、一致性、隔離性和持久性的(ACID),觸發(fā)器和多數(shù)的復(fù)雜查詢。SQLite數(shù)據(jù)庫是Android平臺軟件開發(fā)必備數(shù)據(jù)庫產(chǎn)品!
在Ubuntu 12.04下進(jìn)行SQLite開發(fā)簡單實例如下:
1、 安裝SQLite3
hadron@hadron ~ $ sudo apt-get install sqlite sqlite3
2、 查看版本號
hadron@hadron ~ $ sqlite3 -version
3、 創(chuàng)建test數(shù)據(jù)庫
hadron@hadron ~ $ sqlite3 test.db
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
4、 查看數(shù)據(jù)庫
sqlite> .database
seq name file
--- --------------- ----------------------------------------------------------
0 main /home/hadron/test.db
5、 創(chuàng)建數(shù)據(jù)表
sqlite> create table user(id,username,password);
6、 插入數(shù)據(jù)
sqlite> insert into user(id,username,password) values(1,'abc','123');
7、 查詢數(shù)據(jù)
sqlite> select * from user;
1|abc|123
8、 退出數(shù)據(jù)庫
sqlite> .exit
9、 再次進(jìn)入數(shù)據(jù)庫
hadron@hadron ~ $ sqlite3
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
10、安裝可視化工具:
hadron@hadron ~ $ sudo apt-get install sqlitebrowser