Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> MySQL

Truy vấn MySQL hiển thị cấu trúc bảng

Cú pháp hiển thị cấu trúc bảng:

show create table yourTableName;

Tạo bảng:

mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> EmployeeFirstName varchar(100),    -> EmployeeLastName varchar(100),    -> EmployeeAge int,    -> isMarried tinyint(1),    -> EmployeeAddress varchar(100),    -> EmployeeCountryName varchar(100)    -> ); Query OK, 0 rows affected (0.62 sec)

Hiển thị cấu trúc:

mysql> show create table DemoTable;

Kết quả

+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table        | Create Table                       | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | DemoTable | CREATE TABLE `DemoTable` (   `Id` int(11) NOT NULL AUTO_INCREMENT,   `EmployeeFirstName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,   `EmployeeLastName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,   `EmployeeAge` int(11) DEFAULT NULL,   `isMarried` tinyint(1) DEFAULT NULL,   `EmployeeAddress` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,   `EmployeeCountryName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,   PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)