Sqlite»ù´¡¼°ÆäÓëSQLServerÓï·¨²îÒì
sqlite¹Ù·½Õ¾
http://www.sqlite.org/
SQL Syntax
http://www.sqlite.org/lang.html
sqliteÖÐÎÄÕ¾
http://www.sqlite.com.cn/
http://www.sqlitechina.org/
½¨Á¢Êý¾Ý¿âµµ°¸
ÓÃsqlite3½¨Á¢Êý¾Ý¿âµÄ·½·¨ºÜ¼òµ¥£¬Ö»ÒªÔÚshellϼüÈ루ÒÔÏÂ$·ûºÅΪshellÌáʾºÅ£¬ÇëÎð¼üÈ룩£º
$ sqlite3 foo.db
Èç¹ûĿ¼ÏÂûÓÐfoo.db£¬sqlite3¾Í»á½¨Á¢Õâ¸öÊý¾Ý¿â¡£sqlite3²¢Ã»ÓÐÇ¿ÖÆÊý¾Ý¿âµµÃûÒªÔõôȡ£¬Òò´ËÈç¹ûÄãϲ»¶£¬Ò²¿ÉÒÔÈ¡¸öÀýÈçfoo.icannameitwhateverilikeµÄµµÃû¡£
ÔÚsqlite3ÌáʾÁÐϲÙ×÷
½øÈëÁËsqlite3Ö®ºó£¬»á¿´µ½ÒÔÏÂÎÄ×Ö£º
SQLite version 3.1.3
Enter ".help" for instructions
sqlite>
ÕâʱÈç¹ûʹÓÃ.help¿ÉÒÔÈ¡µÃÇóÖú£¬.quitÔòÊÇÀ뿪£¨Çë×¢Ò⣺²»ÊÇquit£©
SQLµÄÖ¸Áî¸ñʽ
ËùÒÔµÄSQLÖ¸ÁÊÇÒԷֺţ¨;£©½áβµÄ¡£Èç¹ûÓöµ½Á½¸ö¼õºÅ£¨--£©Ôò´ú±í×¢½â£¬sqlite3»áÂÔ¹ýÈ¥¡£
½¨Á¢×ÊÁϱí
¼ÙÉèÎÒÃÇÒª½¨Ò»¸öÃû½ÐfilmµÄ×ÊÁÏ±í£¬Ö»Òª¼üÈëÒÔÏÂÖ¸Áî¾Í¿ÉÒÔÁË£º
create table film(title, length, year, starring);
ÕâÑùÎÒÃǾͽ¨Á¢ÁËÒ»¸öÃû½ÐfilmµÄ×ÊÁÏ±í£¬ÀïÃæÓÐname¡¢length¡¢year¡¢starringËĸö×ֶΡ£
Õâ¸öcreate tableÖ¸ÁîµÄÓ﷨Ϊ£º
create table table_name(field1, field2, field3, ...);
table_nameÊÇ×ÊÁϱíµÄÃû³Æ£¬fieldxÔòÊÇ×ֶεÄÃû×Ö¡£sqlite3ÓëÐí¶àSQLÊý¾Ý¿âÈí¼þ²»Í¬µÄÊÇ£¬Ëü²»ÔÚºõ×Ö¶ÎÊôÓÚÄÄÒ»ÖÖ×ÊÁÏÐÍ̬£ºsqlite3µÄ×ֶοÉÒÔ´¢´æÈκζ«Î÷£ºÎÄ×Ö¡¢Êý×Ö¡¢´óÁ¿ÎÄ×Ö£¨blub£©£¬Ëü»áÔÚÊÊʱ×Ô¶¯×ª»»¡£
½¨Á¢Ë÷Òý
Èç¹û×ÊÁϱíÓÐÏ൱¶àµÄ×ÊÁÏ£¬ÎÒÃDZã»á½¨Á¢Ë÷ÒýÀ´¼Ó¿ìËٶȡ£ºÃ±È˵£º
create index film_title_index on film(title);
Òâ˼ÊÇÕë¶Ôfilm×ÊÁϱíµÄname×ֶΣ¬½¨Á¢Ò»¸öÃû½Ðfilm_name_indexµÄË÷Òý¡£Õâ¸öÖ¸ÁîµÄÓ﷨Ϊ
create index index_name on table_name(field_to_be_indexed);
Ò»µ©½¨Á¢ÁËË÷Òý£¬sqlite3»áÔÚÕë¶Ô¸Ã×Ö¶Î×÷²éѯʱ£¬×Ô¶¯Ê¹ÓøÃË÷Òý¡£ÕâÒ»ÇеIJÙ×÷¶¼ÊÇÔÚÄ»ºó×Ô¶¯·¢ÉúµÄ£¬ÎÞÐëʹÓÃÕßÌرðÖ¸Áî¡£
¼ÓÈëÒ»±Ê×ÊÁÏ
½ÓÏÂÀ´ÎÒÃÇÒª¼ÓÈë×ÊÁÏÁË£¬¼ÓÈëµÄ·½·¨ÎªÊ¹ÓÃinsert intoÖ¸ÁÓ﷨Ϊ£º
insert into table_name values(data1, data2, data3, ...);
ÀýÈçÎÒÃÇ¿ÉÒÔ¼ÓÈë
insert into film values ('Silence of the Lambs, The', 118, 1991, 'Jodie Foster');
insert into film values ('Contact', 153, 1997, 'Jodie Foster');
insert into film values ('Crouching Tiger, Hidden Dragon', 120
Ïà¹ØÎĵµ£º
jdbcÅäÖÃÓï¾äΪ: jdbc:microsoft:sqlserver://server_name:1433
ÈçÔËÐгÌÐòʱ³öÏÖ "Error establishing socket" ´íÎó,ÔòÓ¦½øÐÐÈçϵ÷ÊÔ:
1 ¼ì²éSQL SERVER ÊÇ·ñÔÊÐíÔ¶³Ì·ÃÎÊ.¾ßÌå²½Öè:
1)´ò¿ª"ÆóÒµ¹ÜÀíÆ÷",´ò¿ª¿ØÖÆ̨¸ùĿ¼>SQL Server ×é>Êý¾Ý¿â
2)ÔÚÏàÓ¦"Êý¾Ý¿â"Éϵ¥»÷ÓÒ¼ü,Ñ¡Ôñ"ÊôÐÔ"
3)Ñ¡Ôñ"Á¬½Ó"Ñ ......
ÈçºÎÔÚSqlserverÖдÓÍⲿXMLÎļþÖжÁÈ¡ÅäÖÃÐÅÏ¢ÄØ£¿¸ÃÎÊÌâÔ´×ÔÒ»¼ÒÆóÒµµÄ±ÊÊÔÐÅÏ¢ÓиС£
Ò»xmlÎļþÄÚÈÝ£º
<?xml version="1.0" encoding="utf-8"?>
<root>
<db name="ClientDB1" datasize="512MB" datagrowth="100MB" logsize="100MB" loggrowth ="50MB">
</db>
<db ......
´ÓÍøÉÏÕÒµÄÀý×Ó£¬´´½¨ÁËÒ»¸öÊý¾Ý¿â£¬×·¼ÓÁ˼¸Ìõ¼Ç¼ºó£¬È»ºó¹Ø±ÕÊý¾Ý¿â£¬È»ºó×¼±¸ÏòPDAÏÂÔØÊý¾Ý¿â£¬·¢ÏÖÎļþ¾¹È»±»Õ¼ÓÃÁË£¬ÒѾ¹Ø±ÕÁËÊý¾Ý¿âÁ¬½ÓÒ²ÎÞЧ£¬ºóÀ´´ÓÍøÉÏ¿´µ½ÐèÒªÇå³ýÁ¬½Ó³Ø
using (SQLiteConnection cn = new SQLiteConnection("Data Source=" + strTempPath + "\\Smoke.db3;Pooling=true;FailIfMissing=false ......
/******************************
ϵͳº¯Êý
******************************/
--convert ÓÃÀ´×ª±äÊý¾ÝÀàÐÍ
--convert (data_type[(length)], expression [, style])
select convert(int,convert(varchar(5),12345)+'678')+1 --·µ»Ø12345679
--cast Ò²ÊÇÓÃÀ´×ª»»Êý¾ÝÀàÐÍ
--cast(expression as data_type[(l ......