Computer >> 컴퓨터 >  >> 프로그램 작성 >> MySQL

MySQL에서 캐스케이드를 어떻게 볼 수 있습니까?

<시간/>

캐스케이드를 보려면 MySQL에서 SHOW CREATE 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)

이제 MySQL에서 캐스케이드를 살펴보겠습니다 -

mysql> show create table DemoTable1378;

이것은 다음과 같은 출력을 생성합니다 -

+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 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)