Ispirer Ispirer
Ispirer
 


Ispirer Home Page Ispirer SQLWays Migration Product Page Request SQLWays

How to ensure that Foreign key is converted successfully from MySQL to MSSQL Server?

Foreign keys in MySQL and in MSSQL has the same structure. Structure of the Foreign key in the MSSQL:

  [ FOREIGN KEY ] 
      REFERENCES [ schema_name . ] referenced_table_name [ ( ref_column ) ] 
      [ ON DELETE { NO ACTION | CASCADE | SET NULL | SET DEFAULT } ] 
      [ ON UPDATE { NO ACTION | CASCADE | SET NULL | SET DEFAULT } ] 

Structure of the Foreign key in the MySQL:

  FOREIGN KEY [id] (index_col_name, ...)
      REFERENCES tbl_name (index_col_name, ...)
      [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION}]
      [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION}]

The only difference is RESTRICT word in MySQL database, that has no equivalent in MSSQL database. But in MySQL, foreign key constraints are checked immediately, so NO ACTION and RESTRICT are the same. So during import there is no errors should arise. To check if conversion of the actions of the Foreign keys was successful you should check it in the database.


Ispirer Home Page Ispirer SQLWays Migration Product Page Request SQLWays

sqlways/faq/fk-convert.txt · Last modified: March 20, 2013, 03:53:59 AM (external edit)
 
Ispirer Ispirer © 1999-2017, Ispirer Systems Ltd.
All Rights Reserved.  Privacy Statement