List:General Discussion« Previous MessageNext Message »
From:zzapper Date:May 12 2005 11:49am
Subject: Re: query to lowercase database columns names
View as plain text  
On Wed, 11 May 2005 15:08:50 +0200,  wrote:

>Selon Jay Blanchard <jay.blanchard@stripped>:
>
>> [snip]
>> I've got a converted from Excel spreadsheet to mysql database, which has
>> mixed case column names and

With advice from this thread, what I ended up doing was

>show create table tbl_products;

To get syntax

such

`01_Desc` varchar(255) default NULL,
`01_Lcode` varchar(255) default NULL,

I then used a text editor www.vim.org to generate the following mysql command using VIM
regexp
substitutes

alter table tbl_products 
change `01_Desc` `p01_desc` varchar(255) default NULL,         
change `01_lLcode` `p01_lcode` varchar(255) default NULL, 
etc

eg VIM commands

:%s#^[^ ]\+#change & p\L&
:%s# p`# `p#

This worked very well


-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips

Thread
query to lowercase database columns nameszzapper9 May
  • Re: query to lowercase database columns nameszzapper11 May
    • Re: query to lowercase database columns namesmfatene11 May
  • Re: query to lowercase database columns nameszzapper11 May
RE: Re: query to lowercase database columns namesJay Blanchard11 May
  • RE: Re: query to lowercase database columns namesmfatene11 May
  • Re: query to lowercase database columns nameszzapper12 May