mysql ¹²ÏíËø ÅÅËûËø ·À²åÈëËø
ÊÔÑé1
ÊÂÎñ1£º
#!/usr/bin/python
import time
import MySQLdb;
conn = MySQLdb.connect(host="localhost",port=3306,user="root",passwd="asdf",db="test",unix_socket="/data/mysql_3306/mysql.sock")
cursor = conn.cursor()
cursor.execute("select * from test")
while str!="1":
str = raw_input()
cursor.execute("update test id=id-1")
while str!="exit":
str = raw_input()
cursor.close()
conn.close()
ÔÚmysqlÃüÁîÐÐÖÐÊäÈëÒÔÏ£º
mysql> select * from test;
µ±ÊÂÎñ1ÖеȴýÊäÈë1ʱ£¬ÏÔʾ³öselectÆ¥ÅäµÄÐÐ
µ±ÊÂÎñ1ÖÐÊäÈë1ʱ£¬ÏÔʾ½á¹ûÈçÏ£º
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
½áÂÛ£ºµ±selectʱ»á¼ì²âµ±Ç°ÊÇ·ñÓÐÊÂÎñ»áÐ޸썱ÈÓ°ÏìҪȷÇÐһЩ£©µ±Ç°µÄ¼Ç¼ʱ£¬²Å»á±»×èÈû¡£
ÊÔÑé2
ÔÚÊÂÎñ1£º
#!/usr/bin/python
import time
import MySQLdb;
conn = MySQLdb.connect(host="localhost",port=3306,user="root",passwd="asdf",db="test",unix_socket="/data/mysql_3306/mysql.sock")
cursor = conn.cursor()
cursor.execute("select * from test lock in share mode")
while str!="exit":
str = raw_input()
cursor.close()
conn.close()
ÔÚmysqlÃüÁîÐÐÖÐÊäÈëÒÔÏ£º
mysql> update test set id=id-1;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
½áÂÛ£ºµ±ÊÂÎñÖаüº¬select ...lock in share modeµÄʱºò£¬Ïà¹Ø¼Ç¼½«»á±»Ëø×¡£¬²»ÔÊÐí½øÐÐÐ޸ġ£
ÊÔÑé3
Ö´ÐÐÏÂÃæµÄpython½Å±¾Á½±é£¬²¢ÇÒͬʱÊäÈë1£¬2Ö®ºó
#!/usr/bin/python
import time
import MySQLdb;
conn = MySQLdb.connect(host="localhost",port=3306,user="root",passwd="asdf",db="test",unix_socket="/data/mysql_3306/mysql.sock")
cursor = conn.cursor()
cursor.execute("select * from test lock in share mode")
str = ""
while str!="1":
str = raw_input()
while str!="2":
str = raw_input()
cursor.execute("update test set id=id-1")
while str!="exit":
str = raw_input()
cursor.close()
conn.close()
[root@TJSJHL196-139 tmp]# python test_transaction.py
1
2
Traceback (most recent call la
Ïà¹ØÎĵµ£º
gcc Ç¿´óµÄ±àÒëÆ÷¾Í²»×÷½éÉÜÁË
linuxÏÂÓÃgccÃüÁî±àÒë¶àÏß³ÌC³ÌÐòÎļþºÍº¬ÓÐMySqlÊý¾Ý¿â²Ù×÷Îļþ
1.±àÒë¶àÏß³ÌÎļþ
gcc -o mylti_thread.o multi_thread.c -lpthread
ÆäÖеÄmulti_thread.c±íʾԴÎļþ£¬mylti_thread.o±íʾ±àÒë²úÉúµÄÄ¿±êÎļþ£¬-lpthread±íʾÒýÈë¶àÏ߳̿⣬ÔÚ¡¶Using the GNU Compiler Collection¡·gcc 4. ......
MySQL°²×°Ä¿Â¼ÏµÄDataĿ¼ÖÐ .err´íÎóÐÅÏ¢:
Default storage engine (InnoDB) is not available
½â¾ö°ì·¨:
ɾ³ýÔÚMySQL°²×°Ä¿Â¼ÏµÄDataĿ¼ÖеÄ
ib_logfile0
ib_logfile1
ÖØÐÂÆô¶¯MySQLµÄService ......
ΪʲôÕâÃ´ËµÄØ¡£ÒòΪ°¡ÎÒдÎÒ¹«Ë¾µÄ²éPVµÄÊý¾Ýʱ£¬·¢ÏÖ±íµÄ¹¦Äܲ»ÊǺÜÈ«£¬ÈÃÎÒÓÃÒ»¾ä»°Ð´³öÄÇôÀÏÅ£µÄSQLÓï¾äÕæµÄºÃÄÑ¡£
;̫×Űɣ¬ÎÒд³öÎÒÕâ¾ä»°À´¿´Ò»¿´¡£
<?php
//########################2010-1-24 22£º48
//#######################Êý¾Ý¿â²éѯ
//######################±¾³ÌÐò¹²ÓÐ3¸ösql·Ö±ðΪsql,sql5,sql ......
LIMIT×Ó¾ä¿ÉÒÔ±»ÓÃÀ´ÏÞÖÆSELECTÓï¾ä·µ»ØµÄÐÐÊý¡£LIMITÈ¡1¸ö»ò2¸öÊý×Ö²ÎÊý£¬Èç¹û¸ø¶¨2¸ö²ÎÊý£¬µÚÒ»¸öÖ¸¶¨Òª·µ»ØµÄµÚÒ»ÐÐµÄÆ«ÒÆÁ¿£¬µÚ¶þ¸öÖ¸¶¨·µ»ØÐеÄ×î´óÊýÄ¿¡£³õʼÐÐµÄÆ«ÒÆÁ¿ÊÇ0(²»ÊÇ1)¡£ mysql> select * from table LIMIT 5,10; # Retrieve rows 6-15 Èç¹û¸ø¶¨Ò»¸ö²ÎÊý£¬ËüÖ¸³ö·µ»ØÐеÄ×î´óÊýÄ¿¡£ mysql> select * ......
Oracle,MySQL,MSSQL ServerºÍAccessÊý¾Ý¿âµÄͳ¼Æº¯Êý
ÎÒÃÇÔÚ±à³ÌÖг£ÓõÄͳ¼Æº¯ÊýÓмÆÊý,ÇóºÍ,Çó×î´óÖµ,Çó×îСֵ,Ç󯽾ù,·½²îºÍ±ê×¼²î.
·½²î(Variance)
·½²îÊDZê׼ƫ²îµÄƽ·½¡£×éÖеÄÖµ£¬ÓëËüÃÇÆ½¾ùÖµÖ®¼äÆ«Àë³Ì¶ÈµÄ¶ÈÁ¿¡£
±ê׼ƫ²î(Standard Deviation)
Ò»¸ö²ÎÊý£¬Ö¸³öÒ»ÖÖ·½Ê½£¬Ò»¸ö¸ÅÂʺ¯ÊýÒÔÕâÖÖ·½Ê½·Ö²¼ÔÚÆ½¾ùÖµ¸ ......