How can I view cascades in MySQL?

MySQLMySQLi Database

To view cascades, use SHOW CREATE TABLE in MySQL. Let us first create a table −

mysql> create table DemoTable1378
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> EmployeeId varchar(20),
   -> EmployeeFirstName varchar(20),
   -> EmployeeLastName varchar(20),
   -> EmployeeCountryName varchar(40),
   -> EmployeeAge int,
   -> EmployeeSalary int,
   -> UNIQUE(EmployeeFirstName,EmployeeSalary),
   -> INDEX First_Last_NameIndex(EmployeeFirstName,EmployeeLastName)
   -> );
Query OK, 0 rows affected (0.93 sec)

Let us now view cascades in MySQL −

mysql> show create table DemoTable1378;

This will produce the following output −

+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table         | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DemoTable1378 | CREATE TABLE `demotable1378` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `EmployeeId` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
  `EmployeeFirstName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
  `EmployeeLastName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
  `EmployeeCountryName` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
  `EmployeeAge` int(11) DEFAULT NULL,
  `EmployeeSalary` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `EmployeeFirstName` (`EmployeeFirstName`,`EmployeeSalary`),
  KEY `First_Last_NameIndex` (`EmployeeFirstName`,`EmployeeLastName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.02 sec)
raja
Published on 11-Nov-2019 14:04:46
Advertisements