文章作者:Tyan
博客:noahsnail.com ?|? CSDN ?|? 簡(jiǎn)書(shū)
1. 更新數(shù)據(jù)出錯(cuò)
錯(cuò)誤信息:
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有個(gè)叫SQL_SAFE_UPDATES的變量弯屈,為了數(shù)據(jù)庫(kù)更新操作的安全性网杆,此值默認(rèn)為1喻括。
2. 導(dǎo)入CSV文件
導(dǎo)入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';
碰到的錯(cuò)誤:
Error Code: 13. Can't get stat of '/Users/ltc/Downloads/test.csv' (Errcode: 13 - Permission denied)
infile
前面缺少local
,因?yàn)閷?dǎo)入的是本地文件纯趋。
3. 清空某個(gè)table
命令為:
truncate table tablename;
上面的命令特別之處在于能清理含有自增主鍵的數(shù)據(jù)庫(kù)表。