请教,在MySQL库中已知表名的情况下,如何取得这个表有多少个字段,字段名是什么? 兄弟能不能详细点呢?先谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有两个命令可以得到你想要的结果,见如下操作:mysql> desc employees;+---------------+-------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+---------------+-------------+------+-----+---------+-------+| id | smallint(6) | NO | PRI | | || name | char(255) | NO | | | || fk_department | int(11) | NO | MUL | | |+---------------+-------------+------+-----+---------+-------+3 rows in set (0.20 sec)mysql> show create table employees\G*************************** 1. row *************************** Table: employeesCreate Table: CREATE TABLE `employees` ( `id` smallint(6) NOT NULL, `name` char(255) NOT NULL, `fk_department` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `fk_department` (`fk_department`), CONSTRAINT `employees_ibfk_1` FOREIGN KEY (`fk_department`) REFERENCES `departments` (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf81 row in set (0.00 sec)mysql> 如何设计一个表结构及相关SQL查询语句 一个远程访问MYSQL的问题 基于mysql的日期范围查询 mysql中怎么查看模式默认的搜索路径search_path啊 mysql error--救救我 mysql CPU占用率比较高,怎么查出是哪个连接所引起的? (30)求救,mysql的卸载问题 如何将Excel表中的数据导入到mysql中? 间接相应苦丁兄号召,写了一点点文档,欢迎指正1 一个MYSQL的问题? 如何把查询返回数据映射为xml? 请教查看mysql中database以及table的默认字符集的方法
mysql> desc employees;
+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| id | smallint(6) | NO | PRI | | |
| name | char(255) | NO | | | |
| fk_department | int(11) | NO | MUL | | |
+---------------+-------------+------+-----+---------+-------+
3 rows in set (0.20 sec)mysql> show create table employees\G
*************************** 1. row ***************************
Table: employees
Create Table: CREATE TABLE `employees` (
`id` smallint(6) NOT NULL,
`name` char(255) NOT NULL,
`fk_department` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_department` (`fk_department`),
CONSTRAINT `employees_ibfk_1` FOREIGN KEY (`fk_department`) REFERENCES `depart
ments` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)mysql>