cascading MySQL

Tag Archives: cascading MySQL

How to use Cascade in MySQL 10Dec, 2013

How to use Cascade in MySQL

If you are going to make a change in one table and you want to automatically pass on the change (delete, update) to its dependents, then we use Cascade in MySQL. Let me explain this process by means of an example. Step 1: Create a ‘person’ table. This ‘person’ table must be Innodb. CREATE TABLE IF NOT EXISTS `persons` ( `id` int(11) NOT NULL AUTO_INCREMENT, `last_name` varchar(222) NOT NULL, `first_name` varchar(222) NOT NULL, `address` varchar(222) NOT NULL, `city` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; And insert some data in this table INSERT INTO `persons` (`id`, `last_name`, `first_name`, `address`, `city`) VALUES (2, ‘sharma’, ‘vikas’, ‘mohali’, ‘mohal’), (5, ‘singh’, ‘jaskaran’, ‘mullanput’, ‘mohali’); Step 2: Now create…

Posted in: MySQL