.Tang

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

创建test表

create table test(
id int,
name varchar(10) not null,
age int default 18,
passwd varchar(12),
article text
);

主键索引

alter table test add primary key auto_increment (id);

唯一索引

alter table test add unique (name);       (可同时添加多个字段)

普通索引

alter table test add index (age);  (可同时添加多个字段)

全文索引

alter table test add fulltext (article);

mysql> show create table test\G
*************************** 1. row ***************************
       Table: test
Create Table: CREATE TABLE `test` (
  `id` int(11) NOT NULL,
  `name` varchar(10) NOT NULL,
  `age` int(11) DEFAULT '18',
  `passwd` varchar(12) DEFAULT NULL,
  `article` text,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`),
  KEY `age` (`age`),
  FULLTEXT KEY `article` (`article`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

 

posted on 2018-04-05 19:42  .Tang  阅读(95)  评论(0编辑  收藏  举报