Reducing field lengths

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • News

    Reducing field lengths

    All,
    Initially when I setup my PHP and MySQL site I didn't know much about table
    design. One of the "fixes" I am trying to do is reduce the size of the
    fields to the length of the largest entry.

    Is there an easy script that I can use for each table I have to do this ?
    Some kind of global ALTER ?
    Any ideas ?
    Many thanks.


  • Garp

    #2
    Re: Reducing field lengths


    "News" <news@news.co m> wrote in message
    news:1073cqc8h0 6o21a@corp.supe rnews.com...[color=blue]
    > All,
    > Initially when I setup my PHP and MySQL site I didn't know much about[/color]
    table[color=blue]
    > design. One of the "fixes" I am trying to do is reduce the size of the
    > fields to the length of the largest entry.
    >
    > Is there an easy script that I can use for each table I have to do this ?
    > Some kind of global ALTER ?
    > Any ideas ?
    > Many thanks.
    >
    >[/color]

    I'm going to have to assume a bundle here, but I'm guessing you've got text
    in CHARs, small-range integers in INT(11)s and the like. Your text is almost
    always better off in a VARCHAR (variable length), automatically solving your
    "reduce the size" problem. Moving your numeric fields ought to be a one-off,
    so it shouldn't be too onerous - just how many tables are you adjusting?

    Either way, adjusting those tables with phpMyAdmin will make you feel like
    you're in control.

    And for God's sake, back everything up first...

    Garp


    Comment

    • Tony Marston

      #3
      Re: Reducing field lengths


      "News" <news@news.co m> wrote in message
      news:1073cqc8h0 6o21a@corp.supe rnews.com...[color=blue]
      > All,
      > Initially when I setup my PHP and MySQL site I didn't know much about[/color]
      table[color=blue]
      > design. One of the "fixes" I am trying to do is reduce the size of the
      > fields to the length of the largest entry.
      >
      > Is there an easy script that I can use for each table I have to do this ?
      > Some kind of global ALTER ?
      > Any ideas ?
      > Many thanks.[/color]

      There is no short cut. You will have to create a separate ALTER for each
      table and each column.

      --
      Tony Marston

      This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




      Comment

      • News

        #4
        Re: Reducing field lengths

        Thanks everyone =)

        "Tony Marston" <tony@NOSPAM.de mon.co.uk> wrote in message
        news:c4sjeo$2e8 $1$8300dec7@new s.demon.co.uk.. .[color=blue]
        >
        > "News" <news@news.co m> wrote in message
        > news:1073cqc8h0 6o21a@corp.supe rnews.com...[color=green]
        > > All,
        > > Initially when I setup my PHP and MySQL site I didn't know much about[/color]
        > table[color=green]
        > > design. One of the "fixes" I am trying to do is reduce the size of the
        > > fields to the length of the largest entry.
        > >
        > > Is there an easy script that I can use for each table I have to do this[/color][/color]
        ?[color=blue][color=green]
        > > Some kind of global ALTER ?
        > > Any ideas ?
        > > Many thanks.[/color]
        >
        > There is no short cut. You will have to create a separate ALTER for each
        > table and each column.
        >
        > --
        > Tony Marston
        >
        > http://www.tonymarston.net
        >
        >
        >[/color]


        Comment

        Working...