List:General Discussion« Previous MessageNext Message »
From:Jonathan Mangin Date:May 16 2006 7:17pm
Subject:Re: Converting varchar field into primary key
View as plain text  
----- Original Message ----- 
From: "gerald_clark" <gerald_clark@stripped>
To: "Jonathan Mangin" <jon.mangin@stripped>
Cc: <mysql@stripped>
Sent: Tuesday, May 16, 2006 3:08 PM
Subject: Re: Converting varchar field into primary key


> Jonathan Mangin wrote:
> 
> >>>I'm creating a new MySQL database from an existing Filemaker db.
> >>>
> >>>My problem is that some of the existing 'numbers' in one column (it  
> >>>was a text field in FMP) have leading zeros. eg: 003, 0007, 012,  
> >>>001234. I need to maintain these numbers 'as is' - complete with  
> >>>zeros. I've tried all the numeric data types and they all seem to  
> >>>strip these leading zeros. Is it possible to have a numeric field  
> >>>type which will maintain those zeros? I want this column to become  
> >>>the primary key.
> >>>      
> >>>
> >>"leading zeros" is a typical "display requirement".
> >>
> >>An integer value does not have something as leading zeros.
> >>
> >>Why not make the VARCHAR the PK and keep the datatype?
> >>
> >>Martijn Tonies
> >>Database Workbench - development tool for MySQL, and more!
> >>    
> >>
> >
> >
> >The manual states (among other things) declaring a column:
> >
> >int(6) zerofill
> >
> >will left pad the column with zeros.
> >003 will become 000003.
> >
> >  
> >
> This won't work with his 3, 4, and 6 character examples.
> 
> -- 
Leaving out zerofill will left pad with spaces.
(Tried to encourage the OP to RTM.)


Thread
Converting varchar field into primary keyKim Kohen16 May
  • Re: Converting varchar field into primary keyMartijn Tonies16 May
  • Re: Converting varchar field into primary keyJonathan Mangin16 May
    • Re: Converting varchar field into primary keygerald_clark16 May
  • Re: Converting varchar field into primary keyMartijn Tonies16 May
  • Re: Converting varchar field into primary keyJonathan Mangin16 May