例如,如果列a被定義為unique,並且值為1,則下列語句有同樣的效果,也就是說一旦出入的記錄中存在a=1的情況,直接更新c = c + 1,而不執行c = 3的操作。 複製代碼 代碼如下:insert into table(a, b, c) values (1, 2, 3) on duplicate key update c = c + 1;1 update table set c = c + 1 where a = 1;
解決方案之一:網站訪問出現如題錯誤,經過檢查my.cnf,發現innodb_buffer_pool_size = 2048M 設定過大,調整為innodb_buffer_pool_size = 1024M即可,網上也有該問題的其他解決方案,但都不能解決我的問題。Lost connection to MySQL server at 'reading initial communication packet' 錯誤解決
NOT IN、JOIN、IS NULL、NOT EXISTS效率對比 語句一:select count(*) from A where A.a not in (select a from B) 語句二:select count(*) from A left join B on A.a = B.a where B.a is null 語句三:select count(*) from A where not exists (select a from B where A.a = B.a)
mysql> show global status;可以列出MySQL伺服器運行各種狀態值,另外,查詢MySQL伺服器配置資訊語句:mysql> show variables;一、慢查詢mysql> show variables like ‘%slow%';+——————+——-+| Variable_name | Value |+——————+——-+| log_slow_queries | ON || slow_launch_time | 2
複製代碼 代碼如下:DELIMITER $$ set @stmt = 'select userid,username from myuser where userid between ? and ?'; prepare s1 from @stmt; set @s1 = 2; set @s2 = 100; execute s1 using @s1,@s2; deallocate prepare s1; $$ DELIMITER ; 用這種形式寫的查詢,可以隨意替換參數,給出代碼的人稱之為預先處理,
看到張宴的部落格上關於"http/rest用戶端的文章",怎樣安裝啥的直接都跳過,下面直接進入測試階段,測試環境:虛擬機器 複製代碼 代碼如下:[root@localhost ~]# uname -a Linux sunss 2.6.18-128.el5 #1 SMP Wed Jan 21 10:44:23 EST 2009 i686 i686 i386 GNU/Linux 記憶體和交換分區: 複製代碼 代碼如下:[root@localhost ~]# free -m total used