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

MySQLµÄ×ÔÔö×Ö¶Î


1.¹Ø¼ü×Ö 
auto_increment
2.×ÔÔöÓ÷¨ 
Àý: 
CREATE TABLE animals ( id mediumint not null auto_increment, 
name char(30) not null, 
primary key (id));
3.¹ØÓÚ×ÔÔö
Q:Ôõô»ñµÃµ±Ç°µÄ×ÔÔöµÄ×î´óÖµ?
A:select @@identity
Q:Ôõô»ñµÃtableµÄµ±Ç°×ÔÔö×î´óÖµ? 
A:select max(id) from table
Q:¶Ô×ÔÔöµÄÀí½â? 
A: Ò»°ãÇé¿öÏ»ñÈ¡¸Õ²åÈëµÄÊý¾ÝµÄid£¬Ê¹ÓÃselect max(id) from table ÊÇ¿ÉÒԵġ£LAST_INSERT_ID ÊÇÓëtableÎ޹صģ¬Èç¹ûÏò±ía²åÈëÊý¾Ýºó£¬ÔÙÏò±íb²åÈëÊý¾Ý£¬LAST_INSERT_ID»á¸Ä±ä¡£
ʹÓõ¥INSERTÓï¾ä²åÈë¶àÌõ¼Ç¼, LAST_INSERT_ID·µ»ØÒ»¸öÁÐ±í¡£
@@identityÊDZíʾµÄÊÇ×î½üÒ»´ÎÏò¾ßÓÐidentityÊôÐÔ(¼´×ÔÔöÁÐ)µÄ±í²åÈëÊý¾Ýʱ¶ÔÓ¦µÄ×ÔÔöÁеÄÖµ£¬ÊÇϵͳ¶¨ÒåµÄÈ«¾Ö±äÁ¿¡£±ÈÈçÓиö±íA£¬ËüµÄ×ÔÔöÁÐÊÇid£¬µ±ÏòA±í²åÈëÒ»ÐÐÊý¾Ýºó£¬Èç¹û²åÈëÊý¾Ýºó×ÔÔöÁеÄÖµ×Ô¶¯Ôö¼ÓÖÁ101£¬Ôòͨ¹ýselect@@identityµÃµ½µÄÖµ¾ÍÊÇ101¡£
×¢:LAST_INSERT_IDÊÇÒ»¸öº¯Êý.
Ó÷¨:LAST_INSERT_ID()
Q:MYSQLÖеÄLAST_INSERT_ID()ºÍMSSQLÖеÄ@@IDENTITY 
A:°´ÕÕÓ¦ÓÃÐèÒª£¬³£³£ÒªÈ¡µÃ¸Õ¸Õ²åÈëÊý¾Ý¿â±íÀïµÄ¼Ç¼µÄIDÖµ¡£ 
ÔÚMYSQLÖпÉÒÔʹÓÃLAST_INSERT_ID()º¯Êý£¬ÔÚMSSQLÖÐʹÓÃ@@IDENTITY¡£Í¦·½±ãµÄÒ»¸öº¯Êý¡£
µ«ÊÇ£¬ÕâÀïÐèҪעÒâµÄÊÇ£¬µ±Ê¹ÓÃINSERTÓï¾ä²åÈë¶àÌõ¼Ç¼µÄʱºò£¬Ê¹ÓÃLAST_INSERT_ID()·µ»ØµÄ»¹ÊǵÚÒ»ÌõµÄIDÖµ£¬¶ø@@IDENTITY·µ»Ø×îºóÒ»Ìõ¡£
Q:mysql_insert_id()ÓëLAST_INSERT_ID()
A:mysql_insert_id() ½« MySQL ÄÚ²¿µÄ C API º¯Êý mysql_insert_id() µÄ·µ»Øֵת»»³É long£¨PHPÖÐÃüÃûΪint£©¡£Èç¹û AUTO_INCREMENT µÄÁеÄÀàÐÍÊÇ BIGINT£¬Ôò mysql_insert_id() ·µ»ØµÄÖµ½«²»ÕýÈ·¡£¿ÉÒÔÔÚ SQL²éѯÖÐÓà MySQL ÄÚ²¿µÄ SQL º¯Êý LAST_INSERT_ID() À´Ìæ´ú¡£
MySQLµÄLAST_INSERT_ID()µÄ½éÉÜ mysql_insert_id()¾ÍÊǵ÷ÓÃLAST_INSERT_ID()À´ÊµÏֵġ£
ÔÚmysqlÖÐÓÃlast_insert_id()....ÔÚ³ÌÐòÖÐÓÃmysql_insert_id(). 
ת×Ô£ºhttp://www.linuxidc.com/Linux/2008-08/15068.htm


Ïà¹ØÎĵµ£º

MYSQL³£ÓÃÃüÁîÁбí


MYSQL³£ÓÃÃüÁîÁбí
1¡¢ÏµÍ³¹ÜÀí
mysql -hÖ÷»úµØÖ· -uÓû§Ãû -p 
Á¬½ÓMYSQL£¨ÔÚmysql/bin£©
exit 
Í˳öMYSQLÃüÁî
mysqladmin -uÓû§Ãû -p¾ÉÃÜÂë passwordÐÂÃÜÂë 
ÐÞ¸ÄÃÜÂ루ÔÚmysql/bin£©
grantselect[insert][,update][,delete]onÊý¾Ý¿â.*toÓû§Ãû@localhost£¨"%"£¬ ±íʾÈκÎÖ÷»ú£©identifiedby " ......

mysql ibdata1ÎļþµÄËõС

mysql ibdata1ÎļþµÄËõС(2009-12-22 15:29:46)
±êÇ©£ºit 
 
mysql ibdata1´æ·ÅÊý¾Ý£¬Ë÷ÒýµÈ£¬ÊÇMYSQLµÄ×îÖ÷ÒªµÄÊý¾Ý¡£
Èç¹û²»°ÑÊý¾Ý·Ö¿ª´æ·ÅµÄ»°£¬Õâ¸öÎļþµÄ´óСºÜÈÝÒ×¾ÍÉÏÁËG£¬ÉõÖÁ10+G¡£¶ÔÓÚijЩӦÓÃÀ´Ëµ£¬²¢²»ÊÇÌ«ºÏÊÊ¡£Òò´ËÒª°Ñ´ËÎļþËõС¡£
·½·¨£ºÊý¾ÝÎļþµ¥¶À´æ·Å¡£
²½Ö裺
1£¬±¸·ÝÊý¾Ý¿â
......

ʹÓÃtcmallocºóµÄMySQL·þÎñÆ÷±äÎȶ¨ÁË£¨Linux£©

֮ǰ£¬Ò»Ö±À§ÄպܾõÄMySQLµÄÎÊÌâÒòΪÓÐÁËtcmallocºóµÃÒÔ½â¾ö¡£
ÎÊÌâÊÇ£ºÍøÕ¾·ÃÎÊÁ¿²»¸ß£¬¸ß·åʱ²¢·¢ÊýÔÚ300-400Ö®¼ä¡£CPU±È½Ï¸ß£¬ÔÚ30-80%Ö®¼ä²¨¶¯µÃÀ÷º¦£¬Ê¹ÓÃtopÃüÁî¿ÉÒÔ¿´µ½ÊÇmysql½ø³Ìµ¼Ö£¬Í¬Ê±ÓÃiostatºÍsar²é¿´iowaitÖµºÜ¸ßÔÚ20-30Ö®¼ä¡£
µ«ÊÇϵͳ»¹¿ÉÒÔÎȶ¨ÔËÐУ¬È»ºóÖÜÆÚÐԵijöÏÖswap·ÖÇøÕ¼ÓÃÂÊÅÊÉý£¬Ö±½Óµ¼Ö ......

mysql µÇ¼£¬ÖØÆô

Mysql怬
µÇ¼MySQLµÄÃüÁîÊÇmysql£¬ mysql µÄʹÓÃÓï·¨ÈçÏ£º
¡¡¡¡mysql [-u username] [-h host] [-p[password]] [dbname]
¡¡¡¡username Óë password ·Ö±ðÊÇ MySQL µÄÓû§ÃûÓëÃÜÂ룬mysqlµÄ³õʼ¹ÜÀíÕʺÅÊÇroot£¬Ã»ÓÐÃÜÂ룬עÒ⣺Õâ¸örootÓû§²»ÊÇLinuxµÄϵͳÓû§¡£MySQLĬÈÏÓû§ÊÇroot£¬ÓÉÓÚ³õʼûÓÐÃÜÂ룬µÚÒ»´Î½øʱ ......

°ïÖúÄã´ÓMySQLÒÆÖ²µ½SQL ServerµÄ¹¤¾ß£¨SSMA£©

For SQL Server2008:
http://www.microsoft.com/downloads/details.aspx?FamilyID=0e6168b0-2d0c-4076-96c2-60bd25294a8e&displaylang=en
For SQL Server2005:
http://www.microsoft.com/downloads/details.aspx?familyid=C6F14640-DA22-4604-AAAA-A45DE4A0CD4A&displaylang=en ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ