SQLITE Ò»¸ö±íÖÐÊý¾Ý¸´ÖƵ½ÁíÒ»¸ö±íÖÐ
ÔÚSQLÖÐÓÐÈçÏÂÁ½ÖÖ·½·¨¿ÉÒÔʵÏÖ½«Ò»¸ö±íÖÐÊý¾Ýµ½ÁíÒ»¸ö±íÖÐ
1> select ... into new_tablename from ... where ...
2> insert (into) old_tablename select ... from ... where ...
Çø±ðÊÇÇ°Õß°ÑÊý¾Ý²åÈëÒ»¸öÐÂ±í£¨ÏȽ¨Á¢±í£¬ÔÙ²åÈëÊý¾Ý£©£¬
ºóÕßÊÇ°ÑÊý¾Ý²åÈëÒѾ´æÔÚµÄÒ»¸ö±íÖУ¬ÎÒ¸öÈËϲ»¶ºóÕߣ¬ÒòΪÔÚ±à³ÌµÄ½á¹¹ÉÏ£¬Ó¦Óõķ¶Î§ÉÏ£¬µÚ¶þÌõÓï¾äÇ¿ÓÚÇ°Õß¡£
Ó÷½·¨2¿ÉÔÚSqliteÖÐʵÏÖ½«limitinfoÖв¿·ÖÊý¾Ý¿½±´µ½processlistÖÐ
insert into processlist select null,type,NAME,isuse from limitinfo where mac='00:E0:B1:09:95:C2'
Ö®ËùÒÔselect×Ó¾äµÚÒ»¸öÊÇnull£¬ÊÇÒòΪ±íÖеÚÒ»¸ö²ÎÊýÊÇINTEGER×ÔÔö£¬Ìî³änullºó¿ÉÒÔ±£Ö¤Êý¾ÝIdÊÇ×ÔÔöµÄ¡£
Ïà¹ØÎĵµ£º
SQLite Tutorial in PHP
SQLite is an SQL database manager used locally or on a website, and compatible
in particularly with PHP.
Summary
Installing SQLite and creating a database
.
Installing SQLite. Verifying the installation by creating a base.
Creating and using a SQLite tabl ......
×î½üÔÚÏîÄ¿ÖÐÓõ½ÁËSQLite¡£Ö÷ÒªÊÇ¿Í»§¶ËÓõ½£¬ÕâÖÖСÐÍÄÚǶÊý¾Ý¿â»¹ÊÇÂùʵÓõġ£
ÌáÆðSQLiteÎÒ²»×Ô¾õµÄ¾ÍÏëÆðÁË΢Èí³öµÄACCESS¡£ËûÃÇÁ½¸öȷʵÊÇÓпɱÈÐԵġ£Ôø¾£¬Ð¡ÐÍÍøÕ¾Êý¾Ý¿â£¬ASP¿ÉÒÔÓõ½ACCESS¡£µ«ÊÇ£¬PHPÈ´ÊÇûÓÐÏà¶ÔÓ¦µÄ½â¾ö·½°¸£¬×Ô´ÓSQLiteµÄ³öÏÖ£¬¸øPHPÌṩÁËÒ»¸ö½â¾ö·½°¸¡£
ÔÚ¿Í»§¶ËÀïÃ棬ÎÒÓõ½µÄÊý¾Ý±£ ......
1.ÔÚSQLiteÖвåÈ뵱ǰʱ¼ä,±äÁ¿¶¨Òå²»Óöà˵
char *sql = sqlite3_mprintf("insert into Log VALUES(datetime('now', 'localtime'), '%q', '%q')", cUser, cLogContent);
int ret = sqlite3_exec(Sqlite3, sql, NULL, NULL, &pErrMsg);
ÒÔÔ·ÝΪµ¥Î»Í³¼Æ³ö·ûºÏµ±Ç°Ô·ݵļǼ, TimeΪÊý¾Ý¿âÖÐ×Ö¶ÎÃû:
char *sql = s ......
Ê×ÏÈ×öµãÆ̵æ˵Ã÷£º
sqlite³ÌÐòͨ¹ý²éÕÒ·ÖºÅ(;)À´¾ö¶¨Ò»¸öSQLÓï¾äµÄ½áÊø,ËùÒÔÒªÖ´ÐÐSQLÓï¾äÇëÈ·±£ÔÚSQLÓï¾äºóÓзֺÅ(;).Èç¹ûÄãÊ¡ÂԷֺţ¬sqlite3½«¸øÄãÒ»¸öÁ¬ÐøµÄÃüÁîÌáʾ·û(...> )²¢µÈÄã¸øµ±Ç°µÄSQLÃüÁîÌí¼Ó¸ü¶àµÄÎÄ×Ö¡£Õâ¸öÌصãÈÃÄãÊäÈë¶àÐеĶà¸öSQLÓï¾ä.µ«µãºÅ(.)ÃüÁî²»Òª·ÖºÅ(;).ctrl+c¿ÉÒÔ½áÊøµ±Ç°ÃüÁî¡£
ÔÚdos´ ......
.help ÏÔʾ°ïÖúÐÅÏ¢
.import FILE TABLE °ÑÎļþÖеÄÊý¾Ýµ¼Èëµ½±íÖÐ,¸÷×Ö¶ÎÓÃseparator£¨Ä¬ÈÏÊÇ"|"£©µÄֵΪ·Ö¸ô·û,ÏÂÃæÎÒÃǾٸöÀý×Ó¡£ ÎÒÃÇÔÚFÅÌϽ¨Ò»¸ödata.txtÎļþ£¬ÄÚÈÝÈçÏ£º
4|¿ªÔ´
5|¼¼Êõ
.importÃüÁî²Ù×÷ÈçÏ£º
sqlite> .import data.txt websites
sqlite>
²é¿´½á¹ûÈçÏ£º
sqlite> select * from ......