¡¾×ª¡¿¼ÓËÙ¶¯Ì¬ÍøÕ¾Ö®MySQLË÷Òý·ÖÎöºÍÓÅ»¯
Ò»¡¢Ê²Ã´ÊÇË÷Òý£¿
Ë÷ÒýÓÃÀ´¿ìËÙµØÑ°ÕÒÄÇЩ¾ßÓÐÌض¨ÖµµÄ¼Ç¼£¬ËùÓÐMySQLË÷Òý¶¼ÒÔB-Ê÷µÄÐÎʽ±£´æ¡£Èç¹ûûÓÐË÷Òý£¬Ö´ÐвéѯʱMySQL±ØÐë´ÓµÚÒ»¸ö¼Ç¼¿ªÊ¼É¨ÃèÕû¸ö±íµÄËùÓмǼ£¬Ö±ÖÁÕÒµ½·ûºÏÒªÇóµÄ¼Ç¼¡£±íÀïÃæµÄ¼Ç¼ÊýÁ¿Ô½¶à£¬Õâ¸ö²Ù×÷µÄ´ú¼Û¾ÍÔ½¸ß¡£Èç¹û×÷ΪËÑË÷Ìõ¼þµÄÁÐÉÏÒѾ´´½¨ÁËË÷Òý£¬MySQLÎÞÐèɨÃèÈκμǼ¼´¿ÉѸËٵõ½Ä¿±ê¼Ç¼ËùÔÚµÄλÖá£Èç¹û±íÓÐ1000¸ö¼Ç¼£¬Í¨¹ýË÷Òý²éÕҼǼÖÁÉÙÒª±È˳ÐòɨÃè¼Ç¼¿ì100±¶¡£
¼ÙÉèÎÒÃÇ´´½¨ÁËÒ»¸öÃûΪpeopleµÄ±í£º
¡¡
¡¡
¡¡¡¡CREATE TABLE people ( peopleid SMALLINT NOT NULL,
name CHAR(50) NOT NULL );
¡¡
¡¡
È»ºó£¬ÎÒÃÇÍêÈ«Ëæ»ú°Ñ1000¸ö²»Í¬nameÖµ²åÈëµ½people±í¡£ÔÚÊý¾ÝÎļþÖÐnameÁÐûÓÐÈκÎÃ÷È·µÄ´ÎÐò¡£Èç¹ûÎÒÃÇ´´½¨ÁËnameÁеÄË÷Òý£¬MySQL½«ÔÚË÷ÒýÖÐÅÅÐònameÁÐ,¶ÔÓÚË÷ÒýÖеÄÿһÏMySQLÔÚÄÚ²¿ÎªËü±£´æÒ»¸öÊý¾ÝÎļþÖÐʵ¼Ê¼Ç¼ËùÔÚλÖõēָÕ딡£Òò´Ë£¬Èç¹ûÎÒÃÇÒª²éÕÒnameµÈÓÚ“Mike”¼Ç¼µÄpeopleid£¨SQLÃüÁîΪ“SELECT peopleid from people WHERE name='Mike';”£©£¬MySQLÄܹ»ÔÚnameµÄË÷ÒýÖвéÕÒ“Mike”Öµ£¬È»ºóÖ±½Óתµ½Êý¾ÝÎļþÖÐÏàÓ¦µÄÐУ¬×¼È·µØ·µ»Ø¸ÃÐеÄpeopleid£¨999£©¡£ÔÚÕâ¸ö¹ý³ÌÖУ¬MySQLÖ»Ðè´¦ÀíÒ»¸öÐоͿÉÒÔ·µ»Ø½á¹û¡£Èç¹ûûÓГname”ÁеÄË÷Òý£¬MySQLҪɨÃèÊý¾ÝÎļþÖеÄËùÓмǼ£¬¼´1000¸ö¼Ç¼£¡ÏÔÈ»£¬ÐèÒªMySQL´¦ÀíµÄ¼Ç¼ÊýÁ¿Ô½ÉÙ£¬ÔòËüÍê³ÉÈÎÎñµÄËٶȾÍÔ½¿ì¡£
¶þ¡¢Ë÷ÒýµÄÀàÐÍ
MySQLÌṩ¶àÖÖË÷ÒýÀàÐ͹©Ñ¡Ôñ£º
ÆÕͨË÷Òý
ÕâÊÇ×î»ù±¾µÄË÷ÒýÀàÐÍ£¬¶øÇÒËüûÓÐΨһÐÔÖ®ÀàµÄÏÞÖÆ¡£ÆÕͨË÷Òý¿ÉÒÔͨ¹ýÒÔϼ¸ÖÖ·½Ê½´´½¨£º
´´½¨Ë÷Òý£¬ÀýÈçCREATE INDEX <Ë÷ÒýµÄÃû×Ö> ON tablename (ÁеÄÁбí);
ÐÞ¸Ä±í£¬ÀýÈçALTER TABLE tablename ADD INDEX [Ë÷ÒýµÄÃû×Ö] (ÁеÄÁбí);
´´½¨±íµÄʱºòÖ¸¶¨Ë÷Òý£¬ÀýÈçCREATE TABLE tablename ( [...], INDEX [Ë÷ÒýµÄÃû×Ö] (ÁеÄÁбí) );
ΨһÐÔË÷Òý
ÕâÖÖË÷ÒýºÍÇ°ÃæµÄ“ÆÕͨË÷Òý”»ù±¾Ïàͬ£¬µ«ÓÐÒ»¸öÇø±ð£ºË÷ÒýÁеÄËùÓÐÖµ¶¼Ö»ÄܳöÏÖÒ»´Î£¬¼´±ØÐëΨһ¡£Î¨Ò»ÐÔË÷Òý¿ÉÒÔÓÃÒÔϼ¸ÖÖ·½Ê½´´½¨£º
´´½¨Ë÷Òý£¬ÀýÈçCREATE UNIQUE INDEX <Ë÷ÒýµÄÃû×Ö> ON tablename (ÁеÄÁбí);
ÐÞ¸Ä±í£¬ÀýÈçALTER TABLE tablename ADD UNIQUE [Ë÷ÒýµÄÃû×Ö] (ÁеÄÁбí);
´´½¨±íµÄʱºòÖ¸¶¨Ë÷Òý£¬ÀýÈçCREATE TABLE tablename ( [...], UNIQUE [Ë÷ÒýµÄÃû×Ö] (ÁеÄÁбí) );
Ö÷¼ü
Ïà¹ØÎĵµ£º
×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë
/**
* µ¼ÈëÊý¾Ý
* @param ½Å±¾µÄµØÖ·ºÍÃû³Æ
* @return ÊÇ·ñ³ ......
MySQL :: Linux ÏÂ×Ô¶¯±¸·ÝÊý¾Ý¿âµÄ shell ½Å±¾
Linux ·þÎñÆ÷ÉϵijÌÐòÿÌ춼ÔÚ¸üРMySQL Êý¾Ý¿â£¬ÓÚÊǾÍÏëÆðдһ¸ö shell ½Å±¾£¬½áºÏ crontab£¬¶¨Ê±±¸·ÝÊý¾Ý¿â¡£Æäʵ·Ç³£¼òµ¥£¬Ö÷Òª¾ÍÊÇʹÓà MySQL ×Ô´øµÄ mysqldump ÃüÁî¡£
½Å±¾ÄÚÈÝÈçÏ£º
#!/bin/sh
# File: /home/mysql/backup.sh
# Database info
......
Hibernate ÅäÖÃͨ¹ýc3p0Á¬½ÓMYSQL
** ÐèÒªµÄ°ü: c3p0_versionxx.jar
** hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
&n ......
Ò»¡¢ÔÚ±àÒëʱÓÅ»¯MySQL
Èç¹ûÄã´ÓÔ´´úÂë·Ö·¢°²×°MySQL£¬Òª×¢Ò⣬±àÒë¹ý³Ì¶ÔÒÔºóµÄÄ¿±ê³ÌÐòÐÔÄÜÓÐÖØÒªµÄÓ°Ï죬²»Í¬µÄ±àÒ뷽ʽ¿ÉÄܵõ½ÀàËƵÄÄ¿±êÎļþ£¬µ«ÐÔÄÜ¿ÉÄÜÏà²îºÜ´ó£¬Òò´Ë£¬ÔÚ±àÒë°²×°MySQLÊÊÓ¦×Ðϸ¸ù¾ÝÄãµÄÓ¦ÓÃÀàÐÍÑ¡Ôñ×î¿ÉÄܺõıàÒëÑ¡Ïî¡£ÕâÖÖ¶¨ÖƵÄMySQL¿ÉÒÔΪÄãµÄÓ¦ÓÃÌṩ×î¼ÑÐÔÄÜ¡£
¼¼ÇÉ£ºÑ¡ÓýϺõıà ......
ÔÚApache, PHP, MySQLµÄÌåϵ¼Ü¹¹ÖУ¬MySQL¶ÔÓÚÐÔÄܵÄÓ°Ïì×î´ó£¬Ò²ÊǹؼüµÄºËÐIJ¿·Ö¡£¶ÔÓÚDiscuz!ÂÛ̳³ÌÐòÒ²ÊÇÈç´Ë£¬MySQLµÄÉèÖÃÊÇ·ñºÏÀíÓÅ»¯£¬Ö±½ÓÓ°Ïìµ½ÂÛ̳µÄËٶȺͳÐÔØÁ¿£¡Í¬Ê±£¬MySQLÒ²ÊÇÓÅ»¯ÄѶÈ×î´óµÄÒ»¸ö²¿·Ö£¬²»µ«ÐèÒªÀí½âһЩMySQLרҵ֪ʶ£¬Í¬Ê±»¹ÐèÒª³¤Ê±¼äµÄ¹Û²ìͳ¼Æ²¢ÇÒ¸ù¾Ý¾Ñé½øÐÐÅжϣ¬È»ºóÉèÖúÏÀíµÄ²ÎÊý¡ ......