2010ÄêSQLiteѧϰ±Ê¼ÇÖ®¶þ
2010ÄêSQLiteѧϰ±Ê¼ÇÖ®¶þ
Ò».½¨Á¢Êý¾Ý¿â
sqlite3.exe test.db
¶þ.Ë«»÷sqlite-3_6_16Ŀ¼ÏµijÌÐòsqlite3.exe£¬¼´¿ÉÔËÐÐ
Èý.Í˳ö
.exit
»òÕß
.quit
ËÄ.SQLiteÖ§³ÖÈçÏÂ5ÖÖÊý¾ÝÀàÐÍ
1.NULL£º¿ÕÖµ¡£
2.INTEGER£º´ø·ûºÅµÄÕûÐÍ£¬¾ßÌåÈ¡¾öÓдæÈëÊý×ֵķ¶Î§´óС¡£
3.REAL£º¸¡µãÊý×Ö£¬´æ´¢Îª8-byte IEEE¸¡µãÊý¡£
4.TEXT£º×Ö·û´®Îı¾¡£
5.BLOB£º¶þ½øÖƶÔÏó¡£
Îå.ÁªÏµÈ˱í¸ñ½á¹¹ÈçÏÂ
create table contact(id integer primary key autoincrement,
lastname varchar(20),firstname varchar(20),
mobile varchar(30), telephone varchar(20),
email varchar(30), company varchar(50),
department varchar(16),address varchar(80),
id1 interger,id2 integer, updatetime datetime);
Áù.²é¿´Êý¾Ý¿âÓÐÄÄЩÊý¾Ý±í
ÃüÁîÊÇ£º.tables
Æß.ÈçºÎ²åÈëÒ»Ìõ¼Ç¼
insert into contact(lastname,firstname,mobile,telephone,updatetime) values('Áõ','³©','13910128132','010-81749136','2009-07-22');
°Ë.²é¿´Êý¾Ý±íµÄ½á¹¹
Õë¶ÔÕû¸öÊý¾Ý¿â
.schema
Õë¶Ô½ö½öÊÇcontactÁªÏµÈ˸ñí
.schema contact ×¢ÒâûÓзֺÅ
¾Å.ÈçºÎ´ò¿ªÒ»¸öÒѾ´´½¨µÄÊý¾Ý¿â
sqlite3 test.db
Ê®.ÈçºÎ½â¾öÈçÏÂÎÊÌâ
SQL error: near "sqlite3": syntax error
SQLÖ¸ÁÊÇÒԷֺţ¨;£©½áβµÄ¡£Èç¹ûÓöµ½Á½¸ö¼õºÅ£¨--£©Ôò´ú±í×¢½â£¬sqlite3»áÂÔ¹ýÈ¥
ʮһ.ÈçºÎ½¨Á¢Ë÷Òý
create index index_name on table_name(field_to_be_indexed);
Ê®¶þ.ÈçºÎɾ³ýÒ»ÕÅÊý¾Ý±í
drop table contact;
Ê®Èý.²é¿´µ±Ç°µÄÊý¾Ý¿â
.database
Ê®ËÄ.ÈçºÎɾ³ýÒ»¸öÊý¾Ý±íµÄÊý¾Ý
delete from contact;
Ê®Îå.ÈçºÎµ¼ÈëÒ»¸öÎļþµ½Ä³¸ö±íÖÐ
.import Îļþ·¾¶ ±íÃû
×¢ÒâÕâÊÇ·ÇSQLÓï¾ä£¬ËùÒÔ²»¼Ó·ÖºÅ
Ê®Áù.ÈçºÎÉèÖÃÎļþ×ֶεķָô·û
.separator “,”
.import e:/contact.txt contact
Ê®Æß.ÈçºÎ²é¿´µ±Ç°sqllite×ֶεķָô·ûÊÇʲô£¿
.show
Ê®°Ë.ÈçºÎ½«²éѯ½á¹ûµ¼³öµ½Ò»¸öÎļþ
µÚÒ»²½£º.output a.txt
µÚ¶þ²½£ºÖ´ÐÐÒªµ¼³öµÄSQLÓï¾ä
µÚÈý²½£º.output stdout
Ê®¾Å.SQL²éѯÓï¾ä
select * from film order by year limit 10;
select * from film order by year desc limit 10;
select count(*) from film;
select * from fil
Ïà¹ØÎĵµ£º
SQLiteÇý¶¯Ö§³ÖµÄSQL ÁÐÀàÐÍ
ÀàÐÍÃèÊö
TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB, BYTEA
²»ÏÞÖƳ¤¶ÈµÄ×Ö·û´®ÀàÐÍ. ¶þ½øÖÆÊý¾Ý±ØÐ밲ȫµØ±àÂë´æ´¢, ¼ûtextÀàÐÍ.
CHAR(), VARCHAR(), TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT
²»ÏÞÖƳ¤¶ÈµÄ×Ö·û´®ÀàÐÍ. ²»»á±»½Ø¶Ï»òÕßÌî³ä
ENUM
²»ÏÞÖƳ¤¶ÈµÄ×Ö·û´®ÀàÐÍ. ²»Ïñ MySQL, ʹÓà ......
Sqlite3.3.8ÒÆÖ²
1¡¢ÏÂÔØsqlite-3.3.8.tar.gzÔ´Âë°ü£¬½âѹtar –zxvf sqlite-3.3.8.tar.gz
2¡¢Cd sqlite-3.3.8
3¡¢ÊÖ¶¯ÐÞ¸Ämakefile Îļþ£¬Ä¿Â¼ÏÂÓÐÒ»¸ömakefile°¸ÀýÎļþ: Makefile.linux-gcc
4¡¢ÖØÃüÃûÒ»¸öMakefileÎļþ£¬cp Makefile.linux-gcc Makefile
5¡¢ ´ò¿ªMakefileÎļþ£ºvi Makefile
6¡¢&nb ......
Ò»¡¢SQLite¼ò½é
SQLite ÊÇÓÃCÓïÑÔ±àдµÄ¿ªÔ´Êý¾Ý¿â£¬Ö÷ÒªÓÃÓÚǶÈëʽ£¬ÄãÒ²¿ÉÒÔ°ÑËü¼¯³ÉÔÚ×Ô¼ºµÄ×ÀÃæ³ÌÐòÖУ¬Ò²ÓÐÈ˽«ÆäÌæ´úAccess£¬ÓÃ×÷ºǫ́Êý¾Ý¿â¡£
SQLite Ö§³Ö¶àÊýSQL92±ê×¼£¬ÀýÈ磺Ë÷Òý¡¢ÏÞÖÆ¡¢´¥·¢ºÍ²é¿´Ö§³Ö¡£
Ö§³Ö NULL¡¢INTEGER¡¢REAL¡¢TEXT ºÍ BLOB Êý¾ÝÀàÐÍ£¬Ö§³ÖÊÂÎñ¡£
¶þ¡¢ÏÂÔØSQLite
SQLite¿ÉÒÔµ½¹Ù·½Õ¾µ ......
ʹÓù¤¾ß£º
SQLite Expert SQLiteÊý¾Ý¿â¹ÜÀí¹¤¾ß£¬·Ç³£ºÃÓã¬ÀàËÆÎÒ֮ǰ½éÉܵÄEMS SQL Manager 2007 for MySQL
System.Data.SQLite SQLite For ADO.NETÇý¶¯,ÀàËÆÎÒ֮ǰ½éÉܵÄMySql.Data.dll
Õâ2¸ö¹¤¾ß¶¼°üÀ¨ÁËSQLiteµÄÒýÇæ
1¡¢´Óhttp://www.s ......