1.unique index不能用于text数据类型
2.数据表中一定要有一个数据列
3.my sql有删除保护,
- 打开Workbench的菜单[Edit]->[Preferences...]
- 切换到[SQLEditor]页面
- 把[ForbidUPDATE and DELETE statements without a WHERE clause (safeupdates)]之前的对勾去掉
- 点击[OK]按钮
- 最后一步记得要重启一下Workbench,否则你仍然会得到这个错误提示。
这样设置即可。
4.mysql和python的编码问题,两方都要设置成utf8编码(未验证)
# -*- coding: utf8 -*-
import MySQLdb
conn=MySQLdb.connect(host='localhost',user='root',passwd='1991618',db='abc',port=3306,charset='utf8')
在python中这样编写即可
5.
在 SQL 中增加HAVING 子句原因是,WHERE 关键字无法与合计函数一起使用。
SELECT Customer,SUM(OrderPrice) FROM Orders WHERE Customer='Bush' OR Customer='Adams' GROUP BY Customer HAVING SUM(OrderPrice)>1500
这样即可查询sum>1500的结果
6.在SQL中查询表格中有多少条记录
select count(*) from table_name