Advertisement
Guest User

Untitled

a guest
May 25th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. SELECT
  2. CONCAT('ALTER TABLE ', u1.table_name, ' ADD CONSTRAINT ', u1.CONSTRAINT_NAME, ' FOREIGN KEY (', u1.column_name, ') REFERENCES ', u1.referenced_table_name, ' (', u1.referenced_column_name, ') ON DELETE CASCADE ON UPDATE CASCADE;') as 'sql_query'
  3. FROM information_schema.key_column_usage u1
  4. LEFT JOIN information_schema.key_column_usage u2
  5. ON
  6. u1.table_name = u2.table_name
  7. AND u1.column_name = u2.column_name
  8. AND u2.table_schema = 'magento_dest'
  9. AND u2.referenced_table_name IS NOT NULL
  10. WHERE
  11. u1.referenced_table_name IS NOT NULL
  12. AND u1.table_schema = 'magento_source'
  13. AND u2.table_name IS NULL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement