MySQLÓжàÖÖ´æ´¢ÒýÇ棺
MyISAM¡¢InnoDB¡¢MERGE¡¢MEMORY(HEAP)¡¢BDB(BerkeleyDB)¡¢EXAMPLE¡¢FEDERATED¡¢ARCHIVE¡¢CSV¡¢BLACKHOLE¡£
MySQLÖ§³ÖÊý¸ö´æ´¢ÒýÇæ×÷Ϊ¶Ô²»Í¬±íµÄÀàÐ͵Ĵ¦ÀíÆ÷¡£MySQL´æ´¢ÒýÇæ°üÀ¨´¦ÀíÊÂÎñ°²È«±íµÄÒýÇæºÍ´¦Àí·ÇÊÂÎñ°²È«±íµÄÒýÇ棺
¡ô MyISAM¹ÜÀí·ÇÊÂÎñ±í¡£ËüÌṩ¸ßËÙ´æ´¢ºÍ¼ìË÷£¬ÒÔ¼°È«ÎÄËÑË÷ÄÜÁ¦¡£MyISAMÔÚËùÓÐMySQLÅäÖÃÀï±»Ö§³Ö£¬ËüÊÇĬÈϵĴ洢ÒýÇ棬³ý·ÇÄãÅäÖÃMySQLĬÈÏʹÓÃÁíÍâÒ»¸öÒýÇæ¡£
¡ô MEMORY´æ´¢ÒýÇæÌṩ“ÄÚ´æÖД±í¡£MERGE´æ´¢ÒýÇæÔÊÐí¼¯ºÏ½«±»´¦ÀíͬÑùµÄMyISAM±í×÷Ϊһ¸öµ¥¶ÀµÄ±í¡£¾ÍÏñMyISAMÒ»Ñù£¬MEMORYºÍMERGE´æ´¢ÒýÇæ´¦Àí·ÇÊÂÎñ±í£¬ÕâÁ½¸öÒýÇæÒ²¶¼±»Ä¬ÈÏ°üº¬ÔÚMySQLÖС£
×¢ÊÍ£ºMEMORY´æ´¢ÒýÇæÕýʽµØ±»È·¶¨ÎªHEAPÒýÇæ¡£
¡ô InnoDBºÍBDB´æ´¢ÒýÇæÌṩÊÂÎñ°²È«±í¡£BDB±»°üº¬ÔÚΪ֧³ÖËüµÄ²Ù×÷ϵͳ·¢²¼µÄMySQL-Max¶þ½øÖÆ·Ö·¢°æÀï¡£InnoDBҲĬÈϱ»°üÀ¨ÔÚËù ÓÐMySQL 5.1¶þ½øÖÆ·Ö·¢°æÀÄã¿ÉÒÔ°´ÕÕϲºÃͨ¹ýÅäÖÃMySQLÀ´ÔÊÐí»ò½ûÖ¹ÈÎÒ»ÒýÇæ¡£
¡ô EXAMPLE´æ´¢ÒýÇæÊÇÒ»¸ö“´æ¸ù”ÒýÇ棬Ëü²»×öʲô¡£Äã¿ÉÒÔÓÃÕâ¸öÒýÇæ´´½¨±í£¬µ«Ã»ÓÐÊý¾Ý±»´æ´¢ÓÚÆäÖлò´ÓÆäÖмìË÷¡£Õâ¸öÒýÇæµÄÄ¿µÄÊÇ·þÎñ£¬ÔÚ MySQLÔ´´úÂëÖеÄÒ»¸öÀý×Ó£¬ ......
ÔÚÑ¡Ôñ´æ´¢ÒýÇæʱ£¬Ó¦¸ù¾ÝÓ¦ÓÃÌصãÑ¡ÔñºÏÊʵĴ洢ÒýÇ棬¶ÔÓÚ¸´ÔÓµÄÓ¦ÓÃϵͳ¿ÉÒÔ¸ù¾Ýʵ¼ÊÇé¿öÑ¡Ôñ¶àÖÖ´æ´¢ÒýÇæ½øÐÐ×éºÏ¡£
ÏÂÃæÊdz£Óô洢ÒýÇæµÄÊÊÓû·¾³¡£
¡ñMyISAM:ĬÈϵÄMysql²å¼þʽ´æ´¢ÒýÇæ¡£Èç¹ûÓ¦ÓÃÊÇÒÔ¶ÁдºÍ²åÈë²Ù×÷ΪÖ÷£¬Ö»ÓкÜÉÙ¸üкÍɾ³ý²Ù×÷£¬²¢ÇÒ¶ÔÊÂÎñÍêÕûÐÔ£¬²¢·¢ÐÔÒªÇó²»ÊǺܸߣ¬ÄÇôѡÔñÕâ¸ö´æ´¢ÒýÇæ·Ç³£Êʺϵġ£MyISAMÊÇÔÚWeb£¬Êý¾Ý²Ö´¢ºÍÆäËûÓ¦Óû·¾³ÏÂ×î¾³£Ê¹ÓõĴ洢ÒýÇæÖ®Ò»
¡ñInnoDB:ÓÃÓÚÊÂÎñ´¦ÀíÓ¦ÓóÌÐò£¬Ö§³ÖÍâ¼ü¡£Èç¹ûÓ¦ÓöÔÊÂÎñµÄÍêÕûÐÔÓбȽϸߵÄÒªÇó£¬ÔÚ²¢·¢Ìõ¼þÏÂÒªÇóÊý¾ÝµÄÒ»ÖÂÐÔ£¬Êý¾Ý²Ù×÷³ýÁ˲åÈëºÍ²éѯÒÔÍ⣬»¹°üÀ¨ºÜ¶àµÄ¸üкÍɾ³ý²Ù×÷£¬ÄÇôinnoDB´æ´¢ÒýÇæÓ¦¸ÃÊDZȽϺÏÊʵÄÑ¡Ôñ¡£InnoDB´æ´¢ÒýÇæ³ýÁËÓÐЧµÄ½µµÍÓÉÓÚɾ³ýºÍ¸üе¼ÖµÄËø¶¨£¬»¹¿ÉÒÔÈ·±£ÊÂÎñµÄÍêÕûÌá½»£¨commit£©ºÍ»Ø¹ö£¨rollback£©£¬¶ÔÓÚÀàËƼƷÑϵͳ»òÕß²ÆÎñϵͳµÈ¶ÔÊý¾Ý׼ȷÐÔÒªÇó¸ßµÄϵͳ£¬InnoDBÊDZȽϺÏÊʵÄÑ¡Ôñ¡£
¡ñMEMORY£º½«ËùÓÐÊý¾Ý±£´æÔÚÄÚ´æÖУ¬ÔÚÐèÒª¿ìµÝ¶¨Î»¼Ç¼ºÍÆäËûÀàËÆÊý¾ÝµÄ»·¾³Ï£¬¿ÉÌṩ¼«¿ìµÄ·ÃÎÊ¡£MEMORY µÄȱÏÝÊǶԱíµÄ´óСÓÐÏÞÖÆ£¬Ì«´óµÄ±íÎÞ·¨cacheÔÚÄÚ´æÖУ¬Æä´ÎÊÇҪȷ±£±íµÄÊý¾Ý¿ÉÒÔ»Ö¸´£¬Êý¾Ý¿âÒì³£ÖÕÖ¹ºǫ́±íµÄÊý¾Ý¿ÉÒ ......
Doing INTERSECT and MINUS in MySQL
By Carsten | October 3, 2005
Doing an INTERSECT
An INTERSECT is simply an inner join where we compare the tuples of one table with those of the other, and select those that appear in both while weeding out duplicates. So
SELECT member_id, name from a
INTERSECT
SELECT member_id, name from b
can simply be rewritten to
SELECT a.member_id, a.name
from a INNER JOIN b
USING (member_id, name)
Performing a MINUS
To transform the statement
SELECT member_id, name from a
MINUS
SELECT member_id, name from b
into something that MySQL can process, we can utilize subqueries (available from MySQL 4.1 onward). The easy-to-understand transformation is:
SELECT DISTINCT member_id, name
from a
WHERE (member_id, name) NOT IN
(SELECT member_id, name from table2);
Of course, to any long-time MySQL user, this is immediately obvious as the classical use-left-join-to-find-what-isn’t-in-the-other-table:
SELECT DISTINCT a.member_id, a.name
from a LEFT ......
×î½üÒ»Ö±ÔÚÑо¿freeBSDÏÂnginx+php+mysqlµÄ°²×°£¬¿´Á˺ܶàÍøÉϵÄ×ÊÁÏÊÕ»ñ²»Ð¡£¬²»¹ý´ó²¿·Ö¶¼ÊDZàÒë°²×°£¬Ïà¶Ô³õѧÕßÀ´Ëµ±È½Ï¸´ÔÓ£¬²»ÈÝÒ×Àí½â£¬ËùÒÔÎÒÕûºÏÁËһЩports°²×°µÄ×ÊÁÏ£¬¶¼ÊǾ¹ý×Ô¼ºÑéÖ¤ºóµÄ£¬°²×°³É¹¦Ò²±È½ÏÈÝÒ×Àí½â£¬ÏÂÃæÊÇÁ½Öֳɹ¦µÄ°¸Àý£¬ÆäÖÐÓÐÒ»¸öÊÇApache´úÌænginxµÄ°²×°£¬Ï£Íû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
°²×°Ç°¸üкÃports£º
½øÈëϵͳºó£¬×¼±¸cvs¸üУº
1. cd /usr/ports/net/cvsup-without-gui
2. cp /usr/share/examples/cvsup/ports-supfile /etc/ports-supfile
3. # vi /etc/ports-supfile
½«ÆäÖеÄ#*default host=CHANGE_THIS.FreeBSD.orgÒ»ÐиÄΪ
*default host=cvsup4.FreeBSDchina.org
4. ¸üÐÂports
/usr/local/bin/cvsup -g -L 2 /etc/ports-supfile
1£¬freeBSDÏÂApache+php+mysql°²×°
......
×î½üÒ»Ö±ÔÚÑо¿freeBSDÏÂnginx+php+mysqlµÄ°²×°£¬¿´Á˺ܶàÍøÉϵÄ×ÊÁÏÊÕ»ñ²»Ð¡£¬²»¹ý´ó²¿·Ö¶¼ÊDZàÒë°²×°£¬Ïà¶Ô³õѧÕßÀ´Ëµ±È½Ï¸´ÔÓ£¬²»ÈÝÒ×Àí½â£¬ËùÒÔÎÒÕûºÏÁËһЩports°²×°µÄ×ÊÁÏ£¬¶¼ÊǾ¹ý×Ô¼ºÑéÖ¤ºóµÄ£¬°²×°³É¹¦Ò²±È½ÏÈÝÒ×Àí½â£¬ÏÂÃæÊÇÁ½Öֳɹ¦µÄ°¸Àý£¬ÆäÖÐÓÐÒ»¸öÊÇApache´úÌænginxµÄ°²×°£¬Ï£Íû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
°²×°Ç°¸üкÃports£º
½øÈëϵͳºó£¬×¼±¸cvs¸üУº
1. cd /usr/ports/net/cvsup-without-gui
2. cp /usr/share/examples/cvsup/ports-supfile /etc/ports-supfile
3. # vi /etc/ports-supfile
½«ÆäÖеÄ#*default host=CHANGE_THIS.FreeBSD.orgÒ»ÐиÄΪ
*default host=cvsup4.FreeBSDchina.org
4. ¸üÐÂports
/usr/local/bin/cvsup -g -L 2 /etc/ports-supfile
1£¬freeBSDÏÂApache+php+mysql°²×°
......
C#Á¬½ÓMySQLÊý¾Ý¿â·½·¨
1¡¢ÓÃMySQLDriverCSÁ¬½ÓMySQLÊý¾Ý¿âÏÈÏÂÔغͰ²×°MySQLDriverCS£¬µØÖ·£º
http://sourceforge.net/projects/mysqldrivercs
ÔÚ°²×°Îļþ¼ÐÏÂÃæÕÒµ½MySQLDriver.dll£¬È»ºó½«MySQLDriver.dllÌí¼ÓÒýÓõ½ÏîÄ¿ÖÐ
×¢£ºÎÒÏÂÔصÄÊÇ°æ±¾ÊÇ MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Odbc;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySQLDriverCS;
namespace mysql
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
&nbs ......
C#Á¬½ÓMySQLÊý¾Ý¿â·½·¨
1¡¢ÓÃMySQLDriverCSÁ¬½ÓMySQLÊý¾Ý¿âÏÈÏÂÔغͰ²×°MySQLDriverCS£¬µØÖ·£º
http://sourceforge.net/projects/mysqldrivercs
ÔÚ°²×°Îļþ¼ÐÏÂÃæÕÒµ½MySQLDriver.dll£¬È»ºó½«MySQLDriver.dllÌí¼ÓÒýÓõ½ÏîÄ¿ÖÐ
×¢£ºÎÒÏÂÔصÄÊÇ°æ±¾ÊÇ MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Odbc;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySQLDriverCS;
namespace mysql
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
&nbs ......
php½Ì³Ì mysql½Ì³Ì_connect Óëmysql_pconnectº¯ÊýÓëʵÀý½Ì³Ì
mysql_connect
mysql_connect($this->root,$this->user,$this->pass)
/*
mysql_connect ,µ¥¸ö·´ÎÊÓû§²»»áƵ·±µÄµ÷ÓÃÊý¾Ý¿â½Ì³Ì£¬Ã»±ØÒª±£³ÖÁ¬½Ó£¬¶øÇÒmysqlµÄÁ¬½ÓÊýÒ²ÊÇÓÐÏÞÖƵģ¬ ʹÓà ¼°Ê±·ÃÎʱȽÏƵ·±£¬Ò²×îºÃʹÓÃmysql_connect£¬ÕâÑùʹÓõĹýµÄ×ÊÔ´¿ÉÒÔÁ¢¿ÌÊÍ·Å£¬·ñÔò£¬ÈÝÒ×Ôì³É×ÊÔ´ºÄ
*/
mysql_pconnect
/*
mysql_pconnect() º¯Êý´ò¿ªÒ»¸öµ½ MySQL ·þÎñÆ÷µÄ³Ö¾ÃÁ¬½Ó
*/
$con = mysql_pconnect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
class testLinkMysql{
public $conn;
public $root='localhost';
public $user='root';//'loupan';
public $pass='root';//'loupandsffds';
public $db='dbname';
public $charset='gbk';
public $links='c'; //±êÌâ
function __construct() {
if( !$this->conn )
{
& ......
php½Ì³Ì mysql½Ì³Ì_connect Óëmysql_pconnectº¯ÊýÓëʵÀý½Ì³Ì
mysql_connect
mysql_connect($this->root,$this->user,$this->pass)
/*
mysql_connect ,µ¥¸ö·´ÎÊÓû§²»»áƵ·±µÄµ÷ÓÃÊý¾Ý¿â½Ì³Ì£¬Ã»±ØÒª±£³ÖÁ¬½Ó£¬¶øÇÒmysqlµÄÁ¬½ÓÊýÒ²ÊÇÓÐÏÞÖƵģ¬ ʹÓà ¼°Ê±·ÃÎʱȽÏƵ·±£¬Ò²×îºÃʹÓÃmysql_connect£¬ÕâÑùʹÓõĹýµÄ×ÊÔ´¿ÉÒÔÁ¢¿ÌÊÍ·Å£¬·ñÔò£¬ÈÝÒ×Ôì³É×ÊÔ´ºÄ
*/
mysql_pconnect
/*
mysql_pconnect() º¯Êý´ò¿ªÒ»¸öµ½ MySQL ·þÎñÆ÷µÄ³Ö¾ÃÁ¬½Ó
*/
$con = mysql_pconnect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
class testLinkMysql{
public $conn;
public $root='localhost';
public $user='root';//'loupan';
public $pass='root';//'loupandsffds';
public $db='dbname';
public $charset='gbk';
public $links='c'; //±êÌâ
function __construct() {
if( !$this->conn )
{
& ......