mysql error code 3a 1005

Solutions on MaxInterview for mysql error code 3a 1005 by the best coders in the world

showing results for - "mysql error code 3a 1005"
Alessandra
09 Sep 2020
1/*
2Error Code: 1005 -- there is a wrong primary key reference in your code
3
4Usually it's due to a referenced foreign key field that does not exist. 
5It might be you have a typo mistake, or check case it should be same, or there's a 
6field-type mismatch. Foreign key-linked fields must match definitions exactly.
7
8Some known causes may be:
91. 	The two key fields type and/or size doesn’t match exactly. 
10	For example, if one is INT(10) the key field needs to be INT(10) as well and not INT(11) 
11    or TINYINT. You may want to confirm the field size using SHOW CREATE TABLE because 
12    Query Browser will sometimes visually show just INTEGER for both INT(10) and INT(11). 
13    You should also check that one is not SIGNED and the other is UNSIGNED. 
14    They both need to be exactly the same.
15    
162. 	One of the key field that you are trying to reference does not have an index and/or is not 
17	a primary key. If one of the fields in the relationship is not a primary key, you must 
18    create an index for that field.
19    
203. 	The foreign key name is a duplicate of an already existing key. Check that the name of 
21	your foreign key is unique within your database. Just add a few random characters to the 
22    end of your key name to test for this.
23    
244. 	One or both of your tables is a MyISAM table. In order to use foreign keys, the tables 
25	must both be InnoDB. (Actually, if both tables are MyISAM then you won’t get an error 
26    message - it just won’t create the key.) In Query Browser, you can specify the table type.
27    
285. 	You have specified a cascade ON DELETE SET NULL, but the relevant key field is set to 
29	NOT NULL. You can fix this by either changing your cascade or setting the field to allow 
30    NULL values.
31    
326. 	Make sure that the Charset and Collate options are the same both at the table level 
33	as well as individual field level for the key columns.
34    
357. 	You have a default value (that is, default=0) on your foreign key column.
36
378. 	One of the fields in the relationship is part of a combination (composite) key and 
38	does not have its own individual index. Even though the field has an index as part of 
39    the composite key, you must create a separate index for only that key field in order 
40    to use it in a constraint.
41    
429. 	You have a syntax error in your ALTER statement or you have mistyped one of the 
43	field names in the relationship.
44    
4510. The name of your foreign key exceeds the maximum length of 64 characters.
46*/