ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØʵÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£¬Ïêϸ˵Ã÷ÈçÏ£º
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Data£¨µ¼ÈëÊý¾Ý£©¡£
¡¡¡¡¡ð3ÔÚChoose a Data Source£¨Ñ¡ÔñÊý¾ÝÔ´£©¶Ô»°¿òÖÐÑ¡ÔñMicrosoft Access as the Source£¬È»ºó¼üÈëÄãµÄ.mdbÊý¾Ý¿â(.mdbÎļþÀ©Õ¹Ãû)µÄÎļþÃû»òͨ¹ýä¯ÀÀÑ°ÕÒ¸ÃÎļþ¡£
¡¡¡¡¡ð4ÔÚChoose a Destination£¨Ñ¡ÔñÄ¿±ê£©¶Ô»°¿òÖУ¬Ñ¡ÔñMicrosoft OLE¡¡DB Prov ider for SQL¡¡Server£¬Ñ¡ÔñÊý¾Ý¿â·þÎñÆ÷£¬È»ºóµ¥»÷±ØÒªµÄÑéÖ¤·½Ê½¡£
¡¡¡¡¡ð5ÔÚSpecify Table Copy£¨Ö¸¶¨±í¸ñ¸´ÖÆ£©»òQuery£¨²éѯ£©¶Ô»°¿òÖУ¬µ¥»÷Copy tables£¨¸´ÖƱí¸ñ£© ......
ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØʵÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£¬Ïêϸ˵Ã÷ÈçÏ£º
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Data£¨µ¼ÈëÊý¾Ý£©¡£
¡¡¡¡¡ð3ÔÚChoose a Data Source£¨Ñ¡ÔñÊý¾ÝÔ´£©¶Ô»°¿òÖÐÑ¡ÔñMicrosoft Access as the Source£¬È»ºó¼üÈëÄãµÄ.mdbÊý¾Ý¿â(.mdbÎļþÀ©Õ¹Ãû)µÄÎļþÃû»òͨ¹ýä¯ÀÀÑ°ÕÒ¸ÃÎļþ¡£
¡¡¡¡¡ð4ÔÚChoose a Destination£¨Ñ¡ÔñÄ¿±ê£©¶Ô»°¿òÖУ¬Ñ¡ÔñMicrosoft OLE¡¡DB Prov ider for SQL¡¡Server£¬Ñ¡ÔñÊý¾Ý¿â·þÎñÆ÷£¬È»ºóµ¥»÷±ØÒªµÄÑéÖ¤·½Ê½¡£
¡¡¡¡¡ð5ÔÚSpecify Table Copy£¨Ö¸¶¨±í¸ñ¸´ÖÆ£©»òQuery£¨²éѯ£©¶Ô»°¿òÖУ¬µ¥»÷Copy tables£¨¸´ÖƱí¸ñ£© ......
1 £¬¶ÔÓÚÈÕÆÚ×Ö¶Î×Ö¶Î
access±íʾΪ£º#1981-28-12#
SQLSERVER2000±íʾΪ£º''1981-02-12''
2,SQLÓï¾äÇø±ð£¬select ,update ÔÚ¶Ôµ¥±í²Ù×÷ʱ¶¼²î²»¶à£¬
µ«¶à±í²Ù×÷ʱupdateÓï¾äµÄÇø±ðACCESSÓëSQLSERVERÖеÄUpdateÓï¾ä¶Ô±È:
SQLSERVERÖиüжà±íµÄUpdateÓï¾ä:
Update Tab1
SET a.Name = b.Name
from Tab1 a,Tab2 b
Where a.ID = b.ID;
ͬÑù¹¦ÄܵÄSQLÓï¾äÔÚACCESSÖÐÓ¦¸ÃÊÇ
Update Tab1 a,Tab2 b
SET a.Name = b.Name
Where a.ID = b.ID;
¼´:ACCESSÖеÄUpdateÓï¾äûÓÐfrom×Ó¾ä,ËùÓÐÒýÓÃµÄ±í¶¼ÁÐÔÚUpdate¹Ø¼ü×Öºó.
¸üе¥±íʱ£º¶¼Îª£º
Update table1 set ab='12',cd=444 where ....
3,deleteÓï¾ä
accessÖÐɾ³ýʱÓÃ:delete * from table1 where a>2 ¼´Ö»Òª°Ñselect Óï¾äÀïµÄselect »»³Édelete¾Í¿ÉÒÔÁË¡£
sqlserve ÖÐÔòΪ: delete from table1 where a>2 ¼´Ã»ÓÐ*ºÅ
4£¬as ºóÃæµÄ¼ÆËã×Ö¶ÎÇø±ð
accessÖпÉÒÔÕâÑù£ºselect a,sum(num) as kc_num,kc_num*num as all_kc_num ¼´¿ÉÒÔ°ÑASºóµÄ×ֶε±×÷Ò»¸öÊý¾Ý¿â×ֶβÎÓë¼ÆËã¡£
sqlserver ÖÐÔòΪ£ºselect a,sum(num) as kc_num,sum(num)*num as all_kc_num ¼´²»¿ÉÒÔ°ÑASºóµÄ×ֶε±×÷Ò»¸öÊý¾Ý¿â×ֶβÎÓë¼ÆËã¡£
5£¬[ ......
1 £¬¶ÔÓÚÈÕÆÚ×Ö¶Î×Ö¶Î
access±íʾΪ£º#1981-28-12#
SQLSERVER2000±íʾΪ£º''1981-02-12''
2,SQLÓï¾äÇø±ð£¬select ,update ÔÚ¶Ôµ¥±í²Ù×÷ʱ¶¼²î²»¶à£¬
µ«¶à±í²Ù×÷ʱupdateÓï¾äµÄÇø±ðACCESSÓëSQLSERVERÖеÄUpdateÓï¾ä¶Ô±È:
SQLSERVERÖиüжà±íµÄUpdateÓï¾ä:
Update Tab1
SET a.Name = b.Name
from Tab1 a,Tab2 b
Where a.ID = b.ID;
ͬÑù¹¦ÄܵÄSQLÓï¾äÔÚACCESSÖÐÓ¦¸ÃÊÇ
Update Tab1 a,Tab2 b
SET a.Name = b.Name
Where a.ID = b.ID;
¼´:ACCESSÖеÄUpdateÓï¾äûÓÐfrom×Ó¾ä,ËùÓÐÒýÓÃµÄ±í¶¼ÁÐÔÚUpdate¹Ø¼ü×Öºó.
¸üе¥±íʱ£º¶¼Îª£º
Update table1 set ab='12',cd=444 where ....
3,deleteÓï¾ä
accessÖÐɾ³ýʱÓÃ:delete * from table1 where a>2 ¼´Ö»Òª°Ñselect Óï¾äÀïµÄselect »»³Édelete¾Í¿ÉÒÔÁË¡£
sqlserve ÖÐÔòΪ: delete from table1 where a>2 ¼´Ã»ÓÐ*ºÅ
4£¬as ºóÃæµÄ¼ÆËã×Ö¶ÎÇø±ð
accessÖпÉÒÔÕâÑù£ºselect a,sum(num) as kc_num,kc_num*num as all_kc_num ¼´¿ÉÒÔ°ÑASºóµÄ×ֶε±×÷Ò»¸öÊý¾Ý¿â×ֶβÎÓë¼ÆËã¡£
sqlserver ÖÐÔòΪ£ºselect a,sum(num) as kc_num,sum(num)*num as all_kc_num ¼´²»¿ÉÒÔ°ÑASºóµÄ×ֶε±×÷Ò»¸öÊý¾Ý¿â×ֶβÎÓë¼ÆËã¡£
5£¬[ ......
1.´ò¿ªSQL server enterprise mananger “ÆóÒµ¹ÜÀíÆ÷”
ÔÚÄãÒªµ¼³öµÄSQLÊý¾Ý¿âÉÏÊó±êÓÒ¼ü²Ëµ¥£ºËùÓÐÈÎÎñ-¡·µ¼³öÊý¾Ý
2.»Ø³öÏÖÒ»¸öµ¼³öÏòµ¼´°¿Ú¡£
Ñ¡Ôñ±»µ¼³öµÄÊý¾ÝÔ´£¬ÎªÄã¸Õ²ÅËùÑ¡ÔñµÄÊý¾Ý¿â£¬Èç¹û·¢ÏÖ²»¶ÔÓ¦×ÔÐÐÐ޸ġ£
3.½øÈëµ¼³öµ½Ä¿±êÊý¾ÝÔ´µÄÑ¡Ôñ£¬ÕâÀïÎÒÃÇҪת³ÉACCESSµÄÊý¾Ý¿â¡£×¢ÒâÑ¡ÔñÊý¾ÝÔ´ÀàÐÍΪ“Microsoft Access¡£µã “ÎļþÃû(F)” ºóÃæµÄ°´Å¥Ñ¡ÔñÄ¿±ê.MDBÎļþ¡£
4.Ñ¡Ôñ“´ÓÊý¾Ý¿â¸´ÖƱíºÍÊÓͼ”¡£
5.ÎÒÃÇ×¢ÒâÕâÀïÑ¡±íµÄʱºòÓÒ±ßÓÐÒ»¸ö“ת»»”ÁС£SQLµ¼³öֻת»»Êý¾ÝÀàÐͲ¢²»¿¼ÂÇÆäËû½Å±¾ËùÒÔÎÒÃÇÓöµ½µÄ×Ô¶¯±àºÅÎÊÌâÒ²¾Í³öÔÚÕâÀï¡£ÓÐ×Ô¶¯±àºÅµÄÒ»¶¨ÒªµãÑ¡“ת»»”¡£
6.ÎÒÃǻؿ´µ½Ò»¸ö“ÁÐÓ³ÉäºÍת»»”¶Ô»°¿ò¡£ÓÐ×¢Òâµ½×ÔÔöµÄemployeeid int ×ÔÔöÕâÀï±ä³ÉÁËAccessÀïµÄlongÕâ¿Ï¶¨²»¶Ô£¬long²¢²»ÊÇ×Ô¶¯±àºÅ£¬Ö»ºÃÐ޸Ľ¨±í½Å±¾£¬Í¼Æ¬ÉÏÄǸöºìȦÀïµÄ°´Å¥“±à¼SQL”¡£
¿ªÒ»¸öС´°create talbe
ºìȦÖеĽű¾¾ÍÊÇemployeeid µÄ Access½¨±í½Å±¾£¬ÔÚ “NOT NULL” Ç°Ãæ¼ÓÉÏ “IDENTITY (1, 1)”¡£
7.Á¢¼´Ö´ÐС£
ÏÂͼ±íʾ½¨±í¸´ÖÆÒѳɹ¦
8.ÎÒÃÇ´ò¿ªMDBÎļ ......
1.´ò¿ªSQL server enterprise mananger “ÆóÒµ¹ÜÀíÆ÷”
ÔÚÄãÒªµ¼³öµÄSQLÊý¾Ý¿âÉÏÊó±êÓÒ¼ü²Ëµ¥£ºËùÓÐÈÎÎñ-¡·µ¼³öÊý¾Ý
2.»Ø³öÏÖÒ»¸öµ¼³öÏòµ¼´°¿Ú¡£
Ñ¡Ôñ±»µ¼³öµÄÊý¾ÝÔ´£¬ÎªÄã¸Õ²ÅËùÑ¡ÔñµÄÊý¾Ý¿â£¬Èç¹û·¢ÏÖ²»¶ÔÓ¦×ÔÐÐÐ޸ġ£
3.½øÈëµ¼³öµ½Ä¿±êÊý¾ÝÔ´µÄÑ¡Ôñ£¬ÕâÀïÎÒÃÇҪת³ÉACCESSµÄÊý¾Ý¿â¡£×¢ÒâÑ¡ÔñÊý¾ÝÔ´ÀàÐÍΪ“Microsoft Access¡£µã “ÎļþÃû(F)” ºóÃæµÄ°´Å¥Ñ¡ÔñÄ¿±ê.MDBÎļþ¡£
4.Ñ¡Ôñ“´ÓÊý¾Ý¿â¸´ÖƱíºÍÊÓͼ”¡£
5.ÎÒÃÇ×¢ÒâÕâÀïÑ¡±íµÄʱºòÓÒ±ßÓÐÒ»¸ö“ת»»”ÁС£SQLµ¼³öֻת»»Êý¾ÝÀàÐͲ¢²»¿¼ÂÇÆäËû½Å±¾ËùÒÔÎÒÃÇÓöµ½µÄ×Ô¶¯±àºÅÎÊÌâÒ²¾Í³öÔÚÕâÀï¡£ÓÐ×Ô¶¯±àºÅµÄÒ»¶¨ÒªµãÑ¡“ת»»”¡£
6.ÎÒÃǻؿ´µ½Ò»¸ö“ÁÐÓ³ÉäºÍת»»”¶Ô»°¿ò¡£ÓÐ×¢Òâµ½×ÔÔöµÄemployeeid int ×ÔÔöÕâÀï±ä³ÉÁËAccessÀïµÄlongÕâ¿Ï¶¨²»¶Ô£¬long²¢²»ÊÇ×Ô¶¯±àºÅ£¬Ö»ºÃÐ޸Ľ¨±í½Å±¾£¬Í¼Æ¬ÉÏÄǸöºìȦÀïµÄ°´Å¥“±à¼SQL”¡£
¿ªÒ»¸öС´°create talbe
ºìȦÖеĽű¾¾ÍÊÇemployeeid µÄ Access½¨±í½Å±¾£¬ÔÚ “NOT NULL” Ç°Ãæ¼ÓÉÏ “IDENTITY (1, 1)”¡£
7.Á¢¼´Ö´ÐС£
ÏÂͼ±íʾ½¨±í¸´ÖÆÒѳɹ¦
8.ÎÒÃÇ´ò¿ªMDBÎļ ......
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â====
//Á¬½ÓACCESS(·ÇODBCÁ¬½Óģʽ)
//String dbURL ="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=f:/db1.mdb";
//Á¬½ÓACCESS(ODBC -ϵͳDSNÁ¬½Óģʽ)
//String dbURL="jdbc:odbc:odbcName";
//conn = DriverManager.getConnection(dbURL);//´´½¨Á¬½Ó¶ÔÏó
//System.out.println("ACCESSÊý¾Ý¿âÁ¬½Ó³É¹¦£¡");
//====Á¬½ÓSQLÊý¾Ý¿â====
/*
* String dbURL="jdbc:microsoft:sqlserver://localhost:Êý¾Ý¿â¶Ë¿Ú;DatabaseName=Êý¾Ý¿âÃû";
*
* */
//String dbURL="jdbc:microsoft ......
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â====
//Á¬½ÓACCESS(·ÇODBCÁ¬½Óģʽ)
//String dbURL ="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=f:/db1.mdb";
//Á¬½ÓACCESS(ODBC -ϵͳDSNÁ¬½Óģʽ)
//String dbURL="jdbc:odbc:odbcName";
//conn = DriverManager.getConnection(dbURL);//´´½¨Á¬½Ó¶ÔÏó
//System.out.println("ACCESSÊý¾Ý¿âÁ¬½Ó³É¹¦£¡");
//====Á¬½ÓSQLÊý¾Ý¿â====
/*
* String dbURL="jdbc:microsoft:sqlserver://localhost:Êý¾Ý¿â¶Ë¿Ú;DatabaseName=Êý¾Ý¿âÃû";
*
* */
//String dbURL="jdbc:microsoft ......
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â====
//Á¬½ÓACCESS(·ÇODBCÁ¬½Óģʽ)
//String dbURL ="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=f:/db1.mdb";
//Á¬½ÓACCESS(ODBC -ϵͳDSNÁ¬½Óģʽ)
//String dbURL="jdbc:odbc:odbcName";
//conn = DriverManager.getConnection(dbURL);//´´½¨Á¬½Ó¶ÔÏó
//System.out.println("ACCESSÊý¾Ý¿âÁ¬½Ó³É¹¦£¡");
//====Á¬½ÓSQLÊý¾Ý¿â====
/*
* String dbURL="jdbc:microsoft:sqlserver://localhost:Êý¾Ý¿â¶Ë¿Ú;DatabaseName=Êý¾Ý¿âÃû";
*
* */
//String dbURL="jdbc:microsoft ......
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â====
//Á¬½ÓACCESS(·ÇODBCÁ¬½Óģʽ)
//String dbURL ="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=f:/db1.mdb";
//Á¬½ÓACCESS(ODBC -ϵͳDSNÁ¬½Óģʽ)
//String dbURL="jdbc:odbc:odbcName";
//conn = DriverManager.getConnection(dbURL);//´´½¨Á¬½Ó¶ÔÏó
//System.out.println("ACCESSÊý¾Ý¿âÁ¬½Ó³É¹¦£¡");
//====Á¬½ÓSQLÊý¾Ý¿â====
/*
* String dbURL="jdbc:microsoft:sqlserver://localhost:Êý¾Ý¿â¶Ë¿Ú;DatabaseName=Êý¾Ý¿âÃû";
*
* */
//String dbURL="jdbc:microsoft ......
http://www.umgr.com/blog/PostView.aspx?bpId=36294
1. Ö´ÐÐsqlÓï¾ä
int sqlite3_exec(sqlite3*£¬ const char *sql£¬ sqlite3_callbacksql Óï·¨
£¬ void *£¬ char **errmsg );
Õâ¾ÍÊÇÖ´ÐÐÒ»Ìõ sql Óï¾äµÄº¯Êý¡£
µÚ1¸ö²ÎÊý²»ÔÙ˵ÁË£¬ÊÇÇ°Ãæopenº¯ÊýµÃµ½µÄÖ¸Õ롣˵ÁËÊǹؼüÊý¾Ý½á¹¹¡£
µÚ2¸ö²ÎÊýconst char *sql ÊÇÒ»Ìõ sql Óï¾ä£¬ÒÔ\0½áβ¡£
µÚ3¸ö²ÎÊýsqlite3_callback Êǻص÷£¬µ±ÕâÌõÓï¾äÖ´ÐÐÖ®ºó£¬sqlite3»áÈ¥µ÷ÓÃÄãÌṩµÄÕâ¸öº¯Êý¡£
µÚ4¸ö²ÎÊývoid * ÊÇÄãËùÌṩµÄÖ¸Õësql Óï·¨
£¬Äã¿ÉÒÔ´«µÝÈκÎÒ»¸öÖ¸Õë²ÎÊýµ½ÕâÀÕâ¸ö²ÎÊý×îÖջᴫµ½»Øµ÷º¯ÊýÀïÃ棬Õâ¸öÖ¸Õë±È½ÏÖØÒª£¬¿ÉÒÔÓÃÀ´×÷²ÎÊýµÄ´«µÝ¡£Èç¹û²»ÐèÒª´«µÝÖ¸Õë¸ø»Øµ÷º¯Êý£¬¿ÉÒÔÌîNULL¡£µÈÏÂÎÒÃÇÔÙ¿´»Øµ÷º¯ÊýµÄд·¨£¬ÒÔ¼°Õâ¸ö²ÎÊýµÄʹÓá£
µÚ
5 ¸ö²ÎÊýchar ** errmsg ÊÇ´íÎóÐÅÏ¢¡£×¢ÒâÊÇÖ¸ÕëµÄÖ¸Õë¡£sqlite3ÀïÃæÓкܶà¹Ì¶¨µÄ´íÎóÐÅÏ¢¡£Ö´ÐÐ sqlite3_exec
Ö®ºó£¬Ö´ÐÐʧ°Üʱ¿ÉÒÔ²éÔÄÕâ¸öÖ¸Õ루ֱ½Ó
printf(“%s\n”£¬errmsg)£©µÃµ½Ò»´®×Ö·û´®ÐÅÏ¢£¬Õâ´®ÐÅÏ¢¸æËßÄã´íÔÚʲôµØ·½¡£sqlite3_execº¯Êýͨ¹ýÐÞ¸ÄÄã´«ÈëµÄÖ¸ÕëµÄÖ¸
Õ룬°ÑÄãÌṩµÄÖ¸ÕëÖ¸Ïò´íÎóÌáʾÐÅÏ¢£¬ÕâÑùsqlite3_execº¯ÊýÍâà ......
http://www.umgr.com/blog/PostView.aspx?bpId=36294
1. Ö´ÐÐsqlÓï¾ä
int sqlite3_exec(sqlite3*£¬ const char *sql£¬ sqlite3_callbacksql Óï·¨
£¬ void *£¬ char **errmsg );
Õâ¾ÍÊÇÖ´ÐÐÒ»Ìõ sql Óï¾äµÄº¯Êý¡£
µÚ1¸ö²ÎÊý²»ÔÙ˵ÁË£¬ÊÇÇ°Ãæopenº¯ÊýµÃµ½µÄÖ¸Õ롣˵ÁËÊǹؼüÊý¾Ý½á¹¹¡£
µÚ2¸ö²ÎÊýconst char *sql ÊÇÒ»Ìõ sql Óï¾ä£¬ÒÔ\0½áβ¡£
µÚ3¸ö²ÎÊýsqlite3_callback Êǻص÷£¬µ±ÕâÌõÓï¾äÖ´ÐÐÖ®ºó£¬sqlite3»áÈ¥µ÷ÓÃÄãÌṩµÄÕâ¸öº¯Êý¡£
µÚ4¸ö²ÎÊývoid * ÊÇÄãËùÌṩµÄÖ¸Õësql Óï·¨
£¬Äã¿ÉÒÔ´«µÝÈκÎÒ»¸öÖ¸Õë²ÎÊýµ½ÕâÀÕâ¸ö²ÎÊý×îÖջᴫµ½»Øµ÷º¯ÊýÀïÃ棬Õâ¸öÖ¸Õë±È½ÏÖØÒª£¬¿ÉÒÔÓÃÀ´×÷²ÎÊýµÄ´«µÝ¡£Èç¹û²»ÐèÒª´«µÝÖ¸Õë¸ø»Øµ÷º¯Êý£¬¿ÉÒÔÌîNULL¡£µÈÏÂÎÒÃÇÔÙ¿´»Øµ÷º¯ÊýµÄд·¨£¬ÒÔ¼°Õâ¸ö²ÎÊýµÄʹÓá£
µÚ
5 ¸ö²ÎÊýchar ** errmsg ÊÇ´íÎóÐÅÏ¢¡£×¢ÒâÊÇÖ¸ÕëµÄÖ¸Õë¡£sqlite3ÀïÃæÓкܶà¹Ì¶¨µÄ´íÎóÐÅÏ¢¡£Ö´ÐÐ sqlite3_exec
Ö®ºó£¬Ö´ÐÐʧ°Üʱ¿ÉÒÔ²éÔÄÕâ¸öÖ¸Õ루ֱ½Ó
printf(“%s\n”£¬errmsg)£©µÃµ½Ò»´®×Ö·û´®ÐÅÏ¢£¬Õâ´®ÐÅÏ¢¸æËßÄã´íÔÚʲôµØ·½¡£sqlite3_execº¯Êýͨ¹ýÐÞ¸ÄÄã´«ÈëµÄÖ¸ÕëµÄÖ¸
Õ룬°ÑÄãÌṩµÄÖ¸ÕëÖ¸Ïò´íÎóÌáʾÐÅÏ¢£¬ÕâÑùsqlite3_execº¯ÊýÍâà ......
1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á¬½ÓËüÃÇ£¬
¡¡¡¡ Ê×ÏÈ£¬É¨ÃèµÚÒ»¸ö±í£¨from×Ó¾äÖÐ×îºóµÄÄǸö±í)²¢¶Ô¼Ç¼½øÐÐÅÅÐò£»È»ºóɨÃèµÚ¶þ¸ö±í£¨from×Ó¾äÖÐ×îºóµÚ¶þ¸ö±í)£»×îºó½«ËùÓдӵڶþ¸ö±íÖмìË÷³öµÄ¼Ç¼ÓëµÚÒ»¸ö±íÖкÏÊʼǼ½øÐкϲ¢
¡¡¡¡ ÀýÈç: ±í TAB1 16,384 Ìõ¼Ç¼±í TAB2 5 Ìõ¼Ç¼£¬Ñ¡ÔñTAB2×÷Ϊ»ù´¡±í (×îºÃµÄ·½·¨) select count(*) from tab1,tab2 Ö´ÐÐʱ¼ä0.96Ã룬ѡÔñTAB2×÷Ϊ»ù´¡±í (²»¼ÑµÄ·½·¨) select count(*) from tab2,tab1 Ö´ÐÐʱ¼ä26.09Ã룻
Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ£¬ÄǾÍÐèҪѡÔñ½»²æ±í£¨intersection table£©×÷Ϊ»ù´¡±í£¬½»²æ±íÊÇÖ¸ÄǸö±»ÆäËû±íËùÒýÓÃµÄ±í¡¡¡¡
¡¡¡¡ ÀýÈç:
¡¡¡¡ EMP±íÃèÊöÁËLOCATION±íºÍCATEGORY±íµÄ½»¼¯
¡¡¡¡ SELECT *
¡¡¡¡ from LOCATION L,
¡¡¡¡ CATEGORY C,
¡¡¡¡ EMP E
¡¡¡¡ WHERE E.EMP_NO BETWEEN 1000 AND ......
1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á¬½ÓËüÃÇ£¬
¡¡¡¡ Ê×ÏÈ£¬É¨ÃèµÚÒ»¸ö±í£¨from×Ó¾äÖÐ×îºóµÄÄǸö±í)²¢¶Ô¼Ç¼½øÐÐÅÅÐò£»È»ºóɨÃèµÚ¶þ¸ö±í£¨from×Ó¾äÖÐ×îºóµÚ¶þ¸ö±í)£»×îºó½«ËùÓдӵڶþ¸ö±íÖмìË÷³öµÄ¼Ç¼ÓëµÚÒ»¸ö±íÖкÏÊʼǼ½øÐкϲ¢
¡¡¡¡ ÀýÈç: ±í TAB1 16,384 Ìõ¼Ç¼±í TAB2 5 Ìõ¼Ç¼£¬Ñ¡ÔñTAB2×÷Ϊ»ù´¡±í (×îºÃµÄ·½·¨) select count(*) from tab1,tab2 Ö´ÐÐʱ¼ä0.96Ã룬ѡÔñTAB2×÷Ϊ»ù´¡±í (²»¼ÑµÄ·½·¨) select count(*) from tab2,tab1 Ö´ÐÐʱ¼ä26.09Ã룻
Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ£¬ÄǾÍÐèҪѡÔñ½»²æ±í£¨intersection table£©×÷Ϊ»ù´¡±í£¬½»²æ±íÊÇÖ¸ÄǸö±»ÆäËû±íËùÒýÓÃµÄ±í¡¡¡¡
¡¡¡¡ ÀýÈç:
¡¡¡¡ EMP±íÃèÊöÁËLOCATION±íºÍCATEGORY±íµÄ½»¼¯
¡¡¡¡ SELECT *
¡¡¡¡ from LOCATION L,
¡¡¡¡ CATEGORY C,
¡¡¡¡ EMP E
¡¡¡¡ WHERE E.EMP_NO BETWEEN 1000 AND ......