D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] MySQL Command Line client "edit"

 

On 08/01/13 15:32, Edward Finlayson wrote:
> You could always use mysql in interactive mode.
> I test all my queries there before going 'live' with them.

It is what I've usually done.

I did notice today, on my Wheezy box at least, that editing a query in
vim doesn't seem to return it to mysql consistently. Not sure what it
going on, but either I'm missing something basic or there is some sort
of mangling of the edit results going on.

However my experiences during the week tell me that this is not the way
to carry on doing it.

One of my complex queries was simply picking out an email address via 3
different queries, ranking them, creating a UNION, ordering by rank, and
LIMIT to 1, to pick out the preferred email address.

For various failures to "normalize" the database, this ran into several
hundred bytes of Query.

I realized that my wasted time of debugging one such query that went
wrong (I mistyped a join which probably ought to be based on a foreign
key constraint but anyway), but turns out the ID was an INT and the
column I mistyped was an INT, so the join was valid and worked, I just
got more results than I expected (many versus 1).

Also notice a lot of repeated clauses, which can't be good for
maintenance. Probably means I need a selection of functions or views
defined. Hmm views would probably make a lot of sense for some of
this.... Maybe I need a refresher course on databases, alas an Oracle DB
qualification a long time ago is not what you need when trying to steer
folk in the right direction with programming databases.

On the upside we are mostly losing Windows from this set-up which should
be good for performance, and my sanity. Can't quite lose it all just yet.




-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq