ÔÚ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²ÉÓõÄÊǶ¯Ì¬Êý¾ÝÀàÐÍ£¬»á¸ù¾Ý´æÈëÖµ×Ô¶¯Åжϡ£SQLite¾ßÓÐÒÔÏÂÎåÖÖÊý¾ÝÀàÐÍ£º
1.NULL£º¿ÕÖµ¡£
2.INTEGER£º´ø·ûºÅµÄÕûÐÍ£¬¾ßÌåÈ¡¾öÓдæÈëÊý×ֵķ¶Î§´óС¡£
3.REAL£º¸¡µãÊý×Ö£¬´æ´¢Îª8-byte IEEE¸¡µãÊý¡£
4.TEXT£º×Ö·û´®Îı¾¡£
5.BLOB£º¶þ½øÖƶÔÏó¡£
ת×Ô£ºhttp://www.cnblogs.com/TerryLiang/archive/2009/05/03/1448029.html ......
SQLiteÇý¶¯Ö§³ÖµÄSQL ÁÐÀàÐÍ
ÀàÐÍÃèÊö
TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB, BYTEA
²»ÏÞÖƳ¤¶ÈµÄ×Ö·û´®ÀàÐÍ. ¶þ½øÖÆÊý¾Ý±ØÐ밲ȫµØ±àÂë´æ´¢, ¼ûtextÀàÐÍ.
CHAR(), VARCHAR(), TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT
²»ÏÞÖƳ¤¶ÈµÄ×Ö·û´®ÀàÐÍ. ²»»á±»½Ø¶Ï»òÕßÌî³ä
ENUM
²»ÏÞÖƳ¤¶ÈµÄ×Ö·û´®ÀàÐÍ. ²»Ïñ MySQL, ʹÓà ENUM´úÌæ VARCHAR²»»á½ÚÊ¡´æ´¢¿Õ¼ä.
SET
²»ÏÞÖƳ¤¶ÈµÄ×Ö·û´®ÀàÐÍ. In contrast to MySQL, the input is not checked against the list of allowed values.
YEAR
²»ÏÞÖƳ¤¶ÈµÄ×Ö·û´®ÀàÐÍ. MySQL ÓÃ1¸ö×Ö½Ú ´æ´¢ 2 ¸ö»òÕß 4 ¸öÊý×ÖÄê·Ý, ¶øSQLite ´æΪһ¸ö×Ö·û´®.
TINYINT, INT1, CHAR
A 1 byte type used to store one character, a signed integer between -128 and 127, or an unsigned integer between 0 and 255.
SMALLINT, INT2
2 byte (short) integer type used to store a signed integer between -32768 and 32767 or an unsigned integer between 0 and 65535.
MEDIUMINT
3 byte integer type used to store a signed integer between -8388608 and 8388607 or an unsigned integer between 0 and 16777215.
INT, INTEGER, INT4
4 ......
1¡¢ÈçºÎ½¨Á¢×Ô¶¯Ôö³¤×Ö¶Î?
¼ò¶Ì»Ø´ð£ºÉùÃ÷Ϊ INTEGER PRIMARY KEY µÄÁн«»á×Ô¶¯Ôö³¤¡£
³¤Ò»µãµÄ´ð°¸£º Èç¹ûÄãÉùÃ÷±íµÄÒ»ÁÐΪ INTEGER PRIMARY KEY£¬ÄÇô£¬ ÿµ±ÄãÔÚ¸ÃÁÐÉϲåÈëÒ»NULLֵʱ£¬ NULL×Ô¶¯±»×ª»»ÎªÒ»¸ö±È¸ÃÁÐÖÐ×î´óÖµ´ó1µÄÒ»¸öÕûÊý£¬Èç¹û±íÊǿյģ¬ ½«»áÊÇ1¡£ (Èç¹ûÊÇ×î´ó¿ÉÄܵÄÖ÷¼ü 9223372036854775807£¬ÄǸö£¬½«¼üÖµ½«ÊÇËæ»úδʹÓõÄÊý¡££© È磬ÓÐÏÂÁÐ±í£º
CREATE TABLE t1(
¡¡a INTEGER PRIMARY KEY,
¡¡b INTEGER
);
¡¡¡¡ÔڸñíÉÏ£¬ÏÂÁÐÓï¾ä
INSERT INTO t1 VALUES(NULL,123);
¡¡¡¡ÔÚÂß¼ÉϵȼÛÓÚ£º
INSERT INTO t1 VALUES((SELECT max(a) from t1)+1,123);
¡¡¡¡ÓÐÒ»¸öеÄAPI½Ð×ö sqlite3_last_insert_rowid()£¬ Ëü½«·µ»Ø×î½ü²åÈëµÄÕûÊýÖµ¡£
¡¡¡¡×¢Òâ¸ÃÕûÊý»á±È±íÖиÃÁÐÉϵIJåÈë֮ǰµÄ×î´óÖµ´ó1¡£ ¸Ã¼üÖµÔÚµ±Ç°µÄ±íÖÐÊÇΨһµÄ¡£µ«ÓпÉÄÜÓëÒÑ´Ó±íÖÐɾ³ýµÄÖµÖصþ¡£ ÒªÏ뽨Á¢ÔÚÕû¸ö±íµÄÉúÃüÖÜÆÚÖÐΨһµÄ¼üÖµ£¬ÐèÒªÔÚ INTEGER PRIMARY KEY ÉÏÔö¼ÓAUTOINCREMENTÉùÃ÷¡£ÄÇô£¬ÐµļüÖµ½«»á±È¸Ã±íÖÐÔøÄÜ´æÔÚ¹ýµÄ×î´óÖµ´ó1¡£ Èç¹û×î´ó¿ÉÄܵÄÕûÊýÖµÔÚÊý¾Ý±íÖÐÔø¾´æÔÚ¹ý£¬INSERT½«»áʧ°Ü£¬ ²¢·µ»ØSQLITE_F ......
SQLiteÊý¾Ý¿âµÄÌåϵ½á¹¹(·Òë×Ôsqlite.org)
1 ¼ò½é
±¾ÎĵµÃèÊöÁËSQLite¿âµÄÌåϵ½á¹¹£¬ÕâЩÐÅÏ¢¶ÔÄÇЩÏëÀí½âºÍÐÞ¸ÄSQLiteµÄÄÚ²¿¹¤×÷»úÖƵÄÈËÊÇÓÐÓõġ£
±¾ÎĵµÃèÊöSQLite 3.0°æ±¾£¬2.8°æ»ò¸üÔçÆڵİ汾Óë´ËÏàËÆ£¬Ö»ÊÇϸ½ÚÉÏÓÐËù²»Í¬¡£
2 ½Ó¿Ú
ËäÈ»ÓÐЩº¯Êý·Ö²¼ÔÚÆäËüµÄÎļþÖУ¬µ«ÊÇÖ÷ÒªµÄSQLite¿âµÄ¹«Óýӿں¯ÊýÊÇÔÚmain.c£¬legacy.cºÍvdbeapi.cÔ´´úÂëÎļþÖÐʵÏֵġ£
sqlite3_get_table()º¯ÊýÔÚtable.cÖÐʵÏÖ£¬sqlite3_mprintf()ÔÚprintf.cÖÐʵÏÖ£¬sqlite3_complete()ÊÇÔÚtokenize.cÖÐʵÏֵġ£Tcl½Ó¿Ú
ÔÚtclsqlite.cÖÐʵÏֵġ£¹ØÓÚSQLiteµÄC½Ó¿Ú¸üÍêÕûµÄÐÅÏ¢ÔÚhttp://www.sqlite.org/capi3ref.htmlÖÐÃèÊöÁË¡£
Ϊ±ÜÃâºÍÆäËüÈí¼þµÄÃüÃû³åÍ»£¬SQLite¿âÖÐËùÓеÄÍⲿ·ûºÅ¶¼ÒÔsqlite3Ϊǰ׺¡£ÕâЩ·ûºÅÄ¿µÄ¾ÍÊÇΪÍⲿʹÓ㬻»¾ä»°Ëµ£¬ËùÓÐÒÔ
sqlite3_¿ªÊ¼µÄ·ûºÅ£¬ÐγÉÁËSQLiteµÄAPI¡£
3 ´Ê·¨·ÖÎöÆ÷
µ±Ò»¸öSQLÓï¾äÖ´ÐÐʱ£¬½Ó¿ÚÊ×ÏÈ°Ñ°üº¬¸ÃSQLÓï¾äµÄ×Ö·û´®´«¸ø´Ê·¨·ÖÎöÆ÷À´½øÐд¦Àí¡£´Ê·¨·ÖÎöÆ÷¸ºÔð°Ñ×Ö·û´®·Ö³ÉÒ»¸öÒ»¸öµÄ´Ê·¨µ¥
Ôª£¬È»ºó°Ñ´Ê·¨µ¥Ô ......
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¡¢ Ê×ÏÈÕÒµ½MakefileÎļþÖеÄÏÂÃæÕâÑùÒ»ÐУº
TOP = ../sqlite
½«ÆäÐÞ¸ÄΪ£º
TOP = .
ÕÒµ½ÏÂÃæÕâÑùÒ»ÐУº
TCC = gcc -O6
½«ÆäÐÞ¸ÄΪ£º
TCC = /usr/local/arm/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -O6
ÕÒµ½ÏÂÃæÕâÑùÒ»ÐУº
AR = ar cr
½«ÆäÐÞ¸ÄΪ£º
AR = /usr/local/arm/arm-2009q1/bin/arm-none-linux-gnueabi-ar cr
ÕÒµ½ÏÂÃæÕâÑùÒ»ÐУº
RANLIB = ranlib
½«ÆäÐÞ¸ÄΪ£º
RANLIB = /usr/local/arm/arm-2009q1/bin/arm-none-linux-gnueabi-ranlib
ÕÒµ½ÏÂÃæÕâÑùÒ»ÐУº
MKSHLIB = gcc -shared
½«ÆäÐÞ¸ÄΪ£º
MKSHLIB = /usr/local/arm/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -shared
×¢Ê͵ôÏÂÃæÕâÒ»ÐУº
TCL_FLAGS = -I/home/drh/tcltk/8.4linux
×¢Ê͵ôÏÂÃæÕâÒ»ÐУº
LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a - ......