如果同时为主键的话,可以这样写
alter table abc add num int unsigned primary key auto_increment
__________________________________________
to:数据库强者 不ok
alter table abc change num num int primary key auto_increment前提是你的表中不能存在主键,否则请使用:
alter table abc change num num int auto_increment
一般情况下增长都是主键
mysql>select
*
from
a
+-----+
|
col
|
+-----+
|
0
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
+-----+
8
rows
in
set
(0.00
sec)
mysql>
set
@i
:=
0
select
@i
:=
@i
+
1
as
`order`,
a.*
from
a
order
by
col
desc
+-------+-----+
|
order
|
col
|
+-------+-----+
|
1
|
7
|
|
2
|
6
|
|
3
|
5
|
|
4
|
4
|
|
5
|
3
|
|
6
|
2
|
|
7
|
1
|
|
8
|
0
|
+-------+-----+
8
rows
in
set
(0.00
sec)
mysql>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)