Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Sort of mysql fields

Quote Reply
Sort of mysql fields
Hi all, just got the following problem. In my linkstable i have about 80 fields and some thousands of links in it.
While i fill up the data via the admin and not from extern, i have to search a lot because the fields are not in an alphabetical order.
Now i think about changing the def file to got the sorting i want (10 fields at top, 1 special at the bottom, but the rest via a-z)

Another way could be to recreate the table in the right order i need the fields, but i really have no clue how to enter the data without real handwork.

But somewhere in the deeps of mysql must be an index how the fields are sorted, isnt it so? Then there must be a way to reorder them.
Have someone a clue how i could do this?
Quote Reply
Re: [Robert] Sort of mysql fields In reply to
Heres a couple of discussions:

http://www.gossamer-threads.com/...i?post=208538#208538

http://www.gossamer-threads.com/...i?post=235628#235628
Quote Reply
Re: [Robert] Sort of mysql fields In reply to
If you want to actually reorder your database, the best thing to do is dump/export the data from MySQL Man, where you export just that table, and you export the data with all fields named (the really big export).

Check dump-to-file (so you have it)

Check dump selected tables only, and check the table you want

Check WRITE CREATE TABLE statements, but do *NOT* add a drop table. This is your backup if something goes wrong.

check write INSERT statements and "use Insert statements that name each column to be inserted" the --complete-insert

Then dump the file.

Copy the file to your computer, and look at it in an editor. Make sure you really have all your data.

Now,

Go back to the dump screen, and check "dump to screen".

Select the table again, as before.

Check write create table statement, and drop-table if it exists.

Check DO NOt write table data (--no-data)

----- you just want to get the table SQL create schema codes.

Now, cut/paste the screen dump to an editor, and you can move the lines around. If you have an ID field, I would suggest leaving that as field #1, since it's the unique identifier.

(DO NOT CHANGE ANY NAMES! Just move fields -- whole lines -- around.)

***CHECK*** the create-indexes code, since sometimes the program does not get it right, and you have to manually recreate the indexes. If you don't know what this means, ask before doing it! <G>

Now, comes the part you want to hold your beath for <G>

From the MySQL Man screen, DROP the table -- make it go bye bye.

Now, in the SQL Monitor area, paste in the altered table code, with the fields in the right order. With luck, you'll get no errors.

This will create the new table with the fields in the order you want.

Now... go back to the Links Admin, and pick the table (I'm assuming you are altering your Links table,a nd it shows up on the database page). Pick PROPERTIES and RESYNC the .def files for that table. this is ****VERY**** important! Your old def file is all messed up compared to the new table, and before you do ANYTHING to your Links site, you need to update that def file.

Make sure the new layout on the screen is how you envisioned it, and it's what you wanted.

Now, reimport your data. You can go to the MySQLMan SQLMonitor page and "run queries saved in a file" and use the file on your server, or your harddrive (remember, you did make that backup!). Because you saved the data naming each column, the import will put the data in the right places in the new layout -- as long as you updated your .def file!

Easy, right??

Do it all the time ;)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Sort of mysql fields In reply to
Thank you, Robert.
Seems i had to do it with my normal way, export data to flat, import to excel, sort the rows, export to access, export to flat, import from file to lsql.

And export the mysql-table, sort the text and recreate the table.

But much more im interested in the question how to manipulate the mysql itself so i could change the sort, think where an information is, there must be a way to manipulate it.