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

mysql ×ÔÔöÁÐÏà¹ØÎÊÌâÕûÀí

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().
4.ÈçºÎÖØÖÃÖÖ×Óµ½1£º
truncate ÖØÖÃÖÖ×ÓÖµµ½“1” ¡£
5.select * from table_name where auto_increment_col_name is NULL »ñµÃ×îºó²åÈëµÄµÚÒ»ÐÐÊý¾Ý£»¼´Ê¹Ò»´ÎÐÔ²å´óÅúÊý¾ÝÒ²ÊÇÖ»·µ»Ø¸ÃÅú´ÎµÚÒ»ÐÐ×ÔÔöºóµÄÖµ£¡
ÌØÊâµÄ£º¶ÔÓÚmyisam±í£¬ÌØÊâµÄ¶ÔÓÚmyisamÒýÇæµÄ±í£¬Äã¿ÉÒÔÔÚÒ»¸ö¶àÁÐË÷ÒýÉϵĵڶþÁÐÉ϶¨Òå×ÔÔöÁУº½«ÔÚµÚÒ»Ë÷ÒýÁÐÉϲúÉú×ÔÔö£¬¿ÉÒÔÀí½âΪ£ºÔÚµÚÒ»Ë÷ÒýÁÐÉÏ·Ö×飬¼ÆËã¸Ã×éÉϵÄ×î´óÖµ£¬+1¡£¸ÃÐ


Ïà¹ØÎĵµ£º

dominoÁ¬½Ómysql²åÈëÖÐÎÄÄÚÈݳöÏÖÂÒÂëµÄ½â¾ö·½°¸

    ½üÈÕ£¬ÓÐÒ»¸öÏîÄ¿ÐèҪͨ¹ýOAϵͳ£¨Dominoƽ̨£©ÏòÒ»¸öMySQLÓ¦ÓòåÈë¼Ç¼£¬ÒòΪƽ̨ÊÇwindowsƽ̨£¬ËùÒÔ²ÉÓÃÁËODBCÁ¬½Ó·½Ê½£¬ÔÚOA·þÎñÆ÷ÉÏ°²×°ÁËMyODBC-3.51.11-1Çý¶¯£¬ÅäÖÃÁËODBCÇý¶¯Êý¾ÝÔ´Ö®ºó£¬²åÈë¼Ç¼³É¹¦£¬µ«²»ÂÛÊDzåÈëÖÐÎÄÄÚÈÝ£¬»¹ÊÇ´ÓMySQLÖжÁÈ¡ÖÐÎÄÄÚÈÝ£¬¶¼ÊÇÂÒÂ룬ÔÚÍøÉϲéÔÄÁ˸÷ÖÖ×ÊÁÏ£¬³õ²½ ......

mysql root ÃÜÂëÍü¼Ç£¿£¿£¿£¿

½ñÌì¸øÐÂÀ´µÄÔ±¹¤Á¬½ÓÊý¾Ý¿â£¬ÐÞ¸ÄÁËÒ»ÏÂmysql rootÓû§µÄÃÜÂ룬ÎÒÏÂÔصÄÊÇ´ò°üµÄredMine£¬Ä¬ÈÏÃÜÂëÊÇ¿Õ£¬ÐÞ¸ÄÃÜÂëÖ®ºóÖØÆôredmine£¬phpAdmin Á´½Ó²»ÉÏmysqlÊý¾Ý¿âÁË£¬ÎÒÒ²ÐÞ¸ÄÁËphpadminÎļþ¼ÐϵÄconfig.inc.phpµÄÃÜÂ룬»¹ÊDz»ÐУ¬Ìáʾ#1130 - Host 'localhost' is not allowed to connect to this MySQL server´íÎó£¬Ã÷ ......

ÈÃmysql Äܹ»Ô¶³ÌÁ¬½Ó

mysql error number 2003   
Can't connect to MySQL server xxx.xxx.xxx.xxx (10061)
ÔÚubuntu 9.04ÖÐĬÈÏ°²×°ÁËmysql£¬Ä¬ÈÏÖ»Äܱ¾µØ·ÃÎÊ£¬googleÁËһϣº
²ÉÓÃ
µÇ¼µ½MySQL·þÎñÆ÷¶Ë£¬ÔÚmysql¿âÏÂÖ´ÐÐ
grant all on *.* to 'remote'@'172.16.21.39' identified by 'password';
¼´¿É
Èç¹ûÒªÉèÖÃΪ ......

¿ìËÙµ¼³öµ¼ÈëmysqlÃüÁî


mysqldump -u root -p -e --max_allowed_packet=1048576 --net_buffer_length=16384 msiptv>c:\thedump.sql
ÎÊÌ⣺ÔÚʹÓÃmysql¹ý³ÌÖб¸·ÝÊý¾Ý£¬Ò»°ã¶¼ÊDZ»·Ö³ÉsqlÓï¾äÎı¾£¬µ«mysqldumpÃüÁîĬÈÏÊǷdz£»úеµØ´¦ÀíÓï¾äµÄ×éÖ¯¡£µ¼ÖÂÖØе¼ÈëµÄʱºòЧÂÊÌ«µÍ¡£±ÈÈç10ÍòÌõÊý¾Ý¾ÍÒªÖ´ÐÐ10Íò´ÎµÄsqlÓï¾ä£¬ºÄʱ̫¶à¡£
Ô­Àí£º ......

MySQLÓÅ»¯

MySQLÓÅ»¯
ͬʱÔÚÏß·ÃÎÊÁ¿¼ÌÐøÔö´ó£¬¶ÔÓÚ1GÄÚ´æµÄ·þÎñÆ÷Ã÷ÏԸоõµ½³ÔÁ¦ÑÏÖØʱÉõÖÁÿÌ춼»áËÀ»ú£¬»òÕßʱ²»Ê±µÄ·þÎñÆ÷¿¨Ò»Ï£¬Õâ¸öÎÊÌâÔø¾­À§ÈÅÁËÎÒ°ë¸ö¶àÔ¡£MySQLʹÓÃÊǺܾßÉìËõÐÔµÄËã·¨£¬Òò´ËÄãͨ³£ÄÜÓúÜÉÙµÄÄÚ´æÔËÐлò¸øMySQL¸ü¶àµÄ±»´æÒԵõ½¸üºÃµÄÐÔÄÜ¡£
°²×°ºÃmysqlºó£¬ÅäÖÆÎļþÓ¦¸ÃÔÚ/usr/local/mysql/share/mysql ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ