文章作者:Tyan
博客:noahsnail.com ?|? CSDN ?|? 簡書
1. 更新數據出錯
錯誤信息:
Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect.
解決方案:
set SQL_SAFE_UPDATES = 0;
原因: Mysql有個叫SQL_SAFE_UPDATES的變量,為了數據庫更新操作的安全性,此值默認為1。
2. 導入CSV文件
導入CSV文件的命令為:
load data local infile '/Users/ltc/Downloads/test.csv'
into table `test`
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';
碰到的錯誤:
Error Code: 13. Can't get stat of '/Users/ltc/Downloads/test.csv' (Errcode: 13 - Permission denied)
infile
前面缺少local
,因為導入的是本地文件。
3. 清空某個table
命令為:
truncate table tablename;
上面的命令特別之處在于能清理含有自增主鍵的數據庫表。