List:General Discussion« Previous MessageNext Message »
From:Dan Buettner Date:October 16 2006 6:32pm
Subject:Re: CREATE TABLE Inv_Id
View as plain text  
Hmmm.  When the table is first created, the id number should default
to starting at 1.  Once the table has had entries added and deleted
you can run an ALTER TABLE to reset it to 1, provided it is empty I
think.

There's no way to store an integer left-padded with zeros like that, however.

What you can do is left pad it with zeros whenever you select it:
select LPAD(id,12,0) from Inv_Id order by id;

HTH,
Dan

On 10/16/06, Scott Hamm <linuxgold@stripped> wrote:
> I'm trying to create a table as follows:
>
> CREATE TABLE Inv_Id (
> ID INT(12) AUTO_INCREMENT PRIMARY KEY,
> MID INT NOT NULL,
> FOREIGN (MID) REFERENCES 'Model' (ID)
> );
>
> How do I make ID to start out as '000000000001' for UPC barcode assignment?
> --
> --------------------------------------------------------------------
> `Twas brillig, and the slithy toves
> Did gyre and gimble in the wabe:
> All mimsy were the borogoves,
> And the mome raths outgrabe.
> --------------------------------------------------------------------
>
>
Thread
CREATE TABLE Inv_IdScott Hamm16 Oct
  • Re: CREATE TABLE Inv_IdGerald L. Clark16 Oct
    • Re: CREATE TABLE Inv_IdScott Hamm16 Oct
    • Re: CREATE TABLE Inv_IdRolando Edwards16 Oct
    • Re: CREATE TABLE Inv_IdGabriel PREDA16 Oct
      • Re: CREATE TABLE Inv_IdScott Hamm16 Oct
  • Re: CREATE TABLE Inv_IdDan Buettner16 Oct
  • Re: Re: CREATE TABLE Inv_IdMartijn Tonies19 Oct
    • RE: Re: CREATE TABLE Inv_IdJerry Schwartz19 Oct
Re: CREATE TABLE Inv_IdScott Hamm19 Oct
  • Re: Re: CREATE TABLE Inv_IdDan Buettner19 Oct