MySQL遇到的报错信息(截止到7.18)

-----------------------------------------------------------------7.16---------------------------------------------------------------
1.ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key

mysql> create table grades06(
    -> id int not null auto_increment,
    -> name varchar(12) primary key,
    -> grade float default 0);
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key

自增列只能有1列, 且这列必须为key,改后如下:

mysql>  create table grades06(
    ->  id int not null auto_increment primary key,
    -> name varchar(12),
    -> grade float default 0);
Query OK, 0 rows affected (0.02 sec)

2.Multiple primary key defined
定义了多个主键,我们要知道每个数据表最多只能有一个主键约束。
3.Incorrect prefix key; the used key part isn’t a string, the used length is longer than the key part, or the storage engine doesn’t support unique prefix keys
索引中的的长度超出了字段数据类型定义的长度。解决办法是索引中不写长度,或者把长度改到相应的长度以内。
-----------------------------------------------------------------7.17---------------------------------------------------------------
4.ERROR 1364 (HY000): Field ‘xxxx’ doesn’t have a default value,
字段xxxx为非空约束,不能插入空值。
-----------------------------------------------------------------7.18---------------------------------------------------------------
5.No query specified
在做MySQL主从同步的时候,出现此错误的原因是因为执行命令:show table 表名\G;的时候,多加了一个“;”分号。只要把这个分号删去就好了。
6.ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails
删除有关联的表时必须先删除从表中的数据再删除主表中的数据。
7.ERROR 1054 (42S22): Unknown column ‘字段名’ in 'field list’
1 检查数据库中的字段名与实体类中的字段名是否一致,特别要注意单词字母
2 检查数据库中的字段是否与实体类中的字段一致。比如数据库中没有该字段,实体类中出现了就会报这个错
8.别名的注意事项,使用当你取了别名,那么原本的表名/字段名就不能用了,必须用别名,否则汇报错的
9.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 Queries and reconnect.
MySql运行在safe-updates模式下,该模式会导致非主键条件下无法执行update或者delete命令。
1)show variables like ‘SQL_SAFE_UPDATES’; 查看开关状态。
2)执行命令SET SQL_SAFE_UPDATES = 0; 修改下数据库模式

你可能感兴趣的:(MySQL数据库学习笔记)