Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MYSQL Êֲ᡾ժ¡¿

 20 MySQL¿Í»§¹¤¾ßºÍAPI
20.1 MySQL C API
C API´úÂëÊÇËæMySQL·Ö·¢µÄ£¬Ëü±»°üº¬ÔÚmysqlclient¿âÇÒÔÊÐíC³ÌÐò´æÈ¡Ò»¸öÊý¾Ý¿â¡£
ÔÚ MySQLÔ´´úÂë·Ö·¢Öеĺܶà¿Í»§ÊÇÓÃC±àдµÄ¡£Èç¹ûÄãÕýÔÚÑ°ÕÒÑÝʾÔõÑùʹÓÃC APIµÄÀý×Ó£¬¿´Ò»ÏÂÕâЩ¿Í»§³ÌÐò¡£
´ó¶àÊýÆäËû¿Í»§ API(³ýÁËJavaµÄËùÓÐ)¶¼Ê¹ÓÃmysqlclient¿âÓëMySQL·þÎñÆ÷ͨÐÅ¡£ÕâÒâζ×Å£¬ÀýÈ磬ÄãÄÜÀûÓúܶ౻ÆäËû¿Í»§³ÌÐòʹÓõÄͬһ»·¾³±äÁ¿£¬ÒòΪËûÃÇ´Ó¿âÖÐÒýÓ᣶ÔÕâЩ±äÁ¿µÄÒ»ÕÅ±í£¬¼û12.1 ²»Í¬µÄMySQL³ÌÐòµÄ¸ÅÊö¡£
¿Í»§ÓÐÒ»¸ö×î´óͨѶ»º³åÇø´óС¡£³õʼ·ÖÅäµÄ»º³åÇø´óС(16K×Ö½Ú) ×Ô¶¯µØÔö¼Óµ½×î´ó³ß´ç(ȱʡµÄ×î´óÖµÊÇ24M)¡£ÒòΪ»º³åÇø´óСֻÊÇ°´±£Ö¤ÐèÇó¶ø±»Ôö¼Ó£¬¼òµ¥µØÔö¼ÓȱʡµÄ×î´óÏÞÖƲ¢²»Ôì³É¸ü¶à±»ÏûºÄ¡£¸Ã³ß´ç¼ì²éÖ÷ÒªÊÇÒ»¸ö¶Ô´íÎóµÄ²éѯºÍͨѶ°üµÄ¼ì²é¡£
ͨѶ»º³åÇø±ØÐë×ã¹»´óÒÔ±ãÒ»¸öµ¥¶ÀµÄSQLÓï¾ä(¶Ô¿Í»§-·þÎñÆ÷´«Êä)ºÍÒ»Ðзµ»ØµÄÊý¾Ý(¶Ô·þÎñÆ÷-¿Í»§´«Êä)¡£Ã¿¸öÏ̵߳ÄͨѶ»º³åÇø±»¶¯Ì¬À©´óµ½×î´óÏÞÖÆÀ´´¦ÀíÈκβéѯ»òÐС£ÀýÈ磬Èç¹ûÄã°üº¬´óµ½16MÊý¾ÝµÄBLOBÖµ£¬Äã±ØÐëÓÐÒ»¸öÖÁÉÙ16MͨѶ»º³åÇøÏÞÖÆ(ÔÚ·þÎñÆ÷ºÍ¿Í»§Á½¶Ë)¡£¿Í»§µÄȱʡ×î´óÖµÊÇ24M£¬µ«ÊÇÔÚ·þÎñÆ÷¶ËµÄȱʡ×î´óÖµÊÇ1M¡£Äã¿ÉÒÔÔÚ·þÎñÆ÷Æô¶¯Ê±Í¨¹ý¸Ä±ämax_allowed_packet²ÎÊýµÄÖµÀ´¸Ä±äËü¡£¼û10.2.3 µ÷½Ú·þÎñÆ÷²ÎÊý¡£
MySQL·þÎñÆ÷ÔÚÿ¸ö²éѯºóËõСÿ¸öͨѶ»º³åÇøµ½net_buffer_length¸ö×Ö½Ú¡£¶Ô¿Í»§£¬ÓëÒ»¸öÁ¬½ÓÏà¹ØµÄ»º³åÇøµÄ´óСû±»¼õÉÙ£¬Ö±µ½Á¬½Ó±»¹Ø±Õ£¬ÔÚ´Ëʱ¿Í»§ÄÚ´æ±»»ØÊÕ¡£
Èç¹ûÄãÓÃÏ̵߳ıà³Ì£¬ÄãÓ¦¸ÃÓÃ--with-thread-safe-client±àÒëMySQL C API£¬Õ⽫ʹC APIÏ̶߳Ôÿ¸öÁ¬½Ó¸ü°²È«¡£Äã¿ÉÒÔÈÃ2¸öÏ̹߳²ÏíÏàͬµÄÁ¬½Ó£¬Ö»ÒªÈç¹ûÄã×öÏÂÁÐÊÂÇ飺
Á½¸öÏ̲߳»ÄÜͬʱÔÚͬһ¸öÁ¬½ÓÉÏ·¢ËͲéѯµ½MySQL¡£ÌرðÊÇÄã±ØÐë±£Ö¤ÔÚÒ»¸ömysql_query()ºÍmysql_store_result()Ö®¼äûÓÐÆäËûÏß³ÌÕýÔÚʹÓÃͬһ¸öÁ¬½Ó¡£
Ðí¶àÏß³ÌÄÜ´æÈ¡ÓÃmysql_store_result()¼ìË÷³öÀ´µÄ²»Í¬½á¹û¼¯ºÏ¡£
Èç¹ûÄãʹÓÃmysql_use_result£¬Äã±ØÐ뱣֤ûÓÐÆäËûÏß³ÌÔÚͬһ¸öÁ¬½ÓÉÏÕýÔÚѯÎÊÈκζ«Î÷£¬Ö±µ½½á¹û¼¯ºÏ±»¹Ø±Õ¡£
20.2 C APIÊý¾ÝÀàÐÍ
MYSQL
Õâ¸ö½á¹¹±íʾ¶ÔÒ»¸öÊý¾Ý¿âÁ¬½ÓµÄ¾ä±ú£¬Ëü±»ÓÃÓÚ¼¸ºõËùÓеÄMySQLº¯Êý¡£
MYSQL_RES
Õâ¸ö½á¹¹´ú±í·µ»ØÐеÄÒ»¸ö²éѯµÄ(SELECT, SHOW, DESCRIBE, EXPLAIN)µÄ½á¹û¡£´Ó²éѯ·µ»ØµÄÐÅÏ¢ÔÚ±¾ÕÂÏÂÎijÆΪ½á¹û¼¯ºÏ¡£
MYSQL_ROW
ÕâÊÇÒ»¸öÐÐÊý¾ÝµÄÀàÐÍ°²È«(type-safe)µÄ±íʾ¡£µ±Ç°ËüʵÏÖΪһ¸ö¼ÆÊý×Ö½ÚµÄ×Ö·û´®Ê


Ïà¹ØÎĵµ£º

MySqlÖеÄTimestampÀàÐÍ×ֶεÄʹÓÃ

TIMESTAMPÁÐÀàÐÍÌṩһÖÖÀàÐÍ£¬Äã¿ÉÒÔʹÓÃËü×Ô¶¯µØÓõ±Ç°µÄÈÕÆÚºÍʱ¼ä±ê¼ÇINSERT»òUPDATEµÄ²Ù×÷¡£Èç¹ûÄãÓжà¸öTIMESTAMPÁУ¬Ö»ÓеÚÒ»¸ö×Ô¶¯¸üС£
  ×Ô¶¯¸üеÚÒ»¸öTIMESTAMPÁÐÔÚÏÂÁÐÈκÎÌõ¼þÏ·¢Éú£º
ÁÐûÓÐÃ÷È·µØÔÚÒ»¸öINSERT»òLOAD   DATA   INFILEÓï¾äÖÐÖ¸¶¨¡£     
ÁÐûÓÐÃ÷È·µØÔÚÒ ......

MySQL×Ö·û¼¯µÄÉèÖÃ

¡¾Ç°Ìá¡¿
winxpsp3
mysql5.1
¡¾²½Öè¡¿
1.½øÈëMySQL Command Line Client;
2.ÃüÁ
mysql> show variables like 'character%';
+--------------------------+---------------------------------------------------------+
| Variable_name            | ......

mysql connect by c++

#include <stdio.h>
#include <windows.h>
#include <mysql.h>
#define host "localhost"
#define username "root"
#define password "123"
#define database "oa"
MYSQL *conn;
int main()
{
MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i,ret;
FILE *fp;
MYSQL_FIELD *field; ......

.net·ÃÎÊMysqlһЩϸ½ÚÎÊÌâ

²ÉÓõÄÊÇMySql¹Ù·½ÌṩµÄ.NET connector£¬´ËÇý¶¯Ö»ÐèÒªÏÂÔؼ´¿ÉʹÓãºhttp://dev.mysql.com/downloads/connector/net/1.0.html
   ÔÚʹÓÃÖлýÀÛÁ˼¸µã¾­Ñ飺
    1)ʹÓÃParameter²ÎÊýÐÎʽÌá½»Commandʱ±ØÐëÒª°Ñ"@"ºÅ»»³É"?"ºÅ£¬ÕâÒ»µãÈÃÎÒÀ§»óÁËÒ»Ì죬ֻÊDz»Ã÷°×MySQLΪºÎÒª¸ãÌØÊâÄØ£¬ÏóMS¡¢ODP.NE ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ