sql非主键自增

若是想让一个字段递增,同时这个字段不是主键的情况下,要把这个字段设置成一个键,就可以递增了。

drop database if exists word;
create database word DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
use word;
drop table if exists en_ch;
create table en_ch (
id int not null auto_increment,
en char(100) not null,
ch char(100) not null,
ex char(100),
key(id),# 把id设置为键,就可以实现递增了。
primary key(en)# 主键
)auto_increment=1;
posted @ 2017-06-10 15:45  -梦里不知身是客  阅读(1419)  评论(0编辑  收藏  举报