Code
Alter Table Add constraint
Foreign Key References
on Delete Restrict on Update Restrict;
(constraint can be appended with the constraint name)
The reason for the error is that the IDs of the previous two tables are of different types, one when int, and one when bigint
Workaround when modifying the table,
Alter Table bigint;
You can change it after that.
Here is some information about MySQL
ALTER [ONLINE | OFFLINE] [IGNORE] TABLE tbl_name
[Alter_specification [, Alter_specification] ...]
[Partition_options]
ADD [CONSTRAINT [symbol]]
FOREIGN KEY [index_name] (Index_col_name,...)
Reference_definition
Topic:constraint
SQL supports foreign keys, which let you cross-reference related data across tables, and foreign key constraints, which he LP Keep this spread-out data consistent. The essential syntax for a FOREIGN KEY constraint definition in a CREATE TABLE or ALTER table statement looks like this:
[CONSTRAINT [Symbol]] FOREIGN KEY
[Index_name] (Index_col_name, ...)
REFERENCES tbl_name (Index_col_name,...)
[on DELETE Reference_option]
[on UPDATE Reference_option]
Reference_option:
RESTRICT | CASCADE | SET NULL | NO ACTION
See Also:online Help Create-table-foreign-keys
MySQL add foreign key completion constraint for table error can ' t create table ' Sfkbbs. #sql -513_25 ' (errno:150)