標籤:sql如題:mysql 資料庫重複資料刪除資料因為是mysql 所以其他資料哭的命令在mysql 中是不能使用的。不要想當然的使用sql 指令碼delete from table1where field1 in (select field1 from table1 group by field1 having count(field1) > 1) and rowid not in (select min(rowid) from table1 group by field1
標籤:先看例子:1、delimiter $$2、drop procedure if exists`test_procedure` $$3、create procedure test_procedure(IN puser_id VARCHAR(30),IN pitem_id varchar(45),OUT result INT)4、begin5、select id into result from train_tbl where user_id = puser_id;6、set result=10
標籤:注意:Index(Name,Age)表示在Name,Age兩列上建立聯合索引 由於索引對資料庫的查詢效能有著至關重要的影響,下面是我的一些總結和體會: 一個查詢一次只能使用一個索引:select name from user where name=‘plantegg‘ and age>35 , 如果Index(name); Index(age)的話,MySQL查詢最佳化工具會自動選擇一個索引來使用; MySQL選擇哪個索引,可以這樣來看:mysql> show index
標籤:查看日誌 data/XXX.err 發現如下錯誤[ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace mysql/innodb_index_stats uses space ID: 2 at filepath: .\mysql\innodb_index_stats.ibd. Cannot open tablespace mydatabase/blackboard
標籤:exists對外表用loop逐條查詢,每次查詢都會查看exists的條件陳述式,當 exists裡的條件陳述式能夠返回記錄行時(無論記錄行是的多少,只要能返回),條件就為真,返回當前loop到的這條記錄,反之如果exists裡的條 件語句不能返回記錄行,則當前loop到的這條記錄被丟棄,exists的條件就像一個bool條件,當能返回結果集則為true,不能返回結果集則為 false如下:select * from user where exists (select
標籤:最近搞事務相關的語句,開始搞select for update了,在ECS上做實驗,發現我安裝的版本只支援MyISAM,不支援InnoDB,事務沒法玩。於是在Mac上安裝了一份MySQL Server。如何安裝,如何玩轉,看說明書是最好的~我的機器上,StartupItems安裝失敗了,也不知道為什麼。不過,MySQL Server安裝是成功的,所以採用手動模式啟動就OK了。 shell> cd /usr/local/mysql