关于mysql调整表属性顺序问题
关于mysql调整表属性顺序问题
现在有一张表test
三个字段、name id age
里面已经有很多条数据了、我现在想把id 和name换个顺序、
当然数据库的记录也要调整顺序
请问该怎么搞?谢谢!
现在有一张表test
三个字段、name id age
里面已经有很多条数据了、我现在想把id 和name换个顺序、
当然数据库的记录也要调整顺序
请问该怎么搞?谢谢!
作者: Jerry_BJ 发布时间: 2011-06-09
主键是什么?
如果主键是name,那么建议不要换
用select id,name,age from test一样的结果
另外换字段顺序建议可以用复制表,然后drop原来的表,再复制回来
create table temp as select id,name,age from test;
drop table test;
create table test as select id,name,age from test;
drop table temp;
注:上面建表语句是oracle中的,不知道mysql适合否,楼主可以试试
如果主键是name,那么建议不要换
用select id,name,age from test一样的结果
另外换字段顺序建议可以用复制表,然后drop原来的表,再复制回来
create table temp as select id,name,age from test;
drop table test;
create table test as select id,name,age from test;
drop table temp;
注:上面建表语句是oracle中的,不知道mysql适合否,楼主可以试试
作者: caizhh 发布时间: 2011-06-09
调这个你没有什么意义啊。这不是无聊吗。在显示的时间。你想在哪显示都可以。
不用管数据库的位置。如果你想说看起来方便,那你就弄个客户端,连到你的数据库。
不用管数据库的位置。如果你想说看起来方便,那你就弄个客户端,连到你的数据库。
作者: liuc0317 发布时间: 2011-06-09