Solved

MySQL - Changing order of fields

Posted on 2001-07-10
8
316 Views
Last Modified: 2006-11-17
Hi!

What's the best way of changing the order of fields in a MySQL database.

eg. There are 4 fields in a table.

id
surname
firstname
password

How do you change the order to...

id
password
firstname
surname


Cheers,

Mel
0
Comment
Question by:melvynmyers
8 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6269089
Why do you want to change the order of the fields? For the display, you can (and should) always query the fields in the order you want, and if you are developing a software on your own, you don't care the order.
I'm not sure, but MySQL should support views, in which you can order the fields as you like, and issue the SELECT * FROM YourView as you want...
CHeers
0
 
LVL 1

Author Comment

by:melvynmyers
ID: 6271746
The main reason is for commands like...

INSERT INTO table VALUES ('abc','123','etc','etc');


It makes life a little easier for me.

Cheers,

Mel

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6271965
If you build the view(s) as i mentionned, you should be able to insert into the view also...
Not sure because i'm not MySQL expert, but that works for all the databases i know of (SQL Server, Oracle, Access)
CHeers
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 3

Expert Comment

by:ahoor
ID: 6272403
So what's wrong with giving a column list?

INSERT INTO table (id, password, firstname,surname)
VALUES ('abc','123','etc','etc');


Arjan


0
 
LVL 1

Author Comment

by:melvynmyers
ID: 6275564
angel, I don't believe MySQL supprts views.

Arjan, thanks for your input. Your solution will work, but ideally I still want to change the field order.

Cheers!

0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 6275801
As i said, i'm not a MySQL expert...
But in any database, you can only drop and recreate the table. To maintain the data, you can copy it to a temporary table...

CHeers
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7258959

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - Answered by: angelIII
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Expert Comment

by:Jgould
ID: 7289055
Question has been closed as per recommendation

JGould-EE Moderator
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question