发表于 2018-10-6 08:56:49

mysql(三)-数据库操作

create index 索引名 on 表名(需要索引的字段)  create index index_name on city(name);
  *************************** 3. row ***************************
  Table: city
  Non_unique: 1
  Key_name: index_name       这里是索引名
  Seq_in_index: 1
  Column_name: Name
  Collation: A
  Cardinality: 184
  Sub_part: NULL
  Packed: NULL
  Null:
  Index_type: BTREE
  Comment:
  Index_comment:
  同时,查看表结构的时候,发现在Name中的key栏出现了MUL
  desc city
  -> ;
  +-------------+----------+------+-----+---------+----------------+
  | Field       | Type   | Null | Key | Default | Extra          |
  +-------------+----------+------+-----+---------+----------------+

  |>  | Name      | char(35) | NO   | MUL |         |                |
  | CountryCode | char(3)| NO   | MUL |         |                |
  | District    | char(20) | NO   |   |         |                |
  | Population| int(11)| NO   |   | 0       |                |
  +-------------+----------+------+-----+---------+----------------+

页: [1]
查看完整版本: mysql(三)-数据库操作