要显示有关字段名称的信息,语法如下:
show columns from yourTableName;
让我们首先创建一个表-
mysql> create table DemoTable1586 -> ( -> EmployeeId int, -> EmployeeFirstName varchar(20), -> EmployeeLastName varchar(20), -> EmployeeAge int, -> EmployeeCountryName varchar(20), -> EmployeeSalary int -> );
以下是显示字段名称的查询-
mysql> show columns from DemoTable1586;
这将产生以下输出-
+---------------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------------+-------------+------+-----+---------+-------+ | EmployeeId | int(11) | YES | | NULL | | | EmployeeFirstName | varchar(20) | YES | | NULL | | | EmployeeLastName | varchar(20) | YES | | NULL | | | EmployeeAge | int(11) | YES | | NULL | | | EmployeeCountryName | varchar(20) | YES | | NULL | | | EmployeeSalary | int(11) | YES | | NULL | | +---------------------+-------------+------+-----+---------+-------+ 6 rows in set (0.11 sec)