By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,639 Members | 3,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,639 IT Pros & Developers. It's quick & easy.

Reducing field lengths

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"News" <ne**@news.com> wrote in message
news:10*************@corp.supernews.com...
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.


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
Jul 17 '05 #2

P: n/a

"News" <ne**@news.com> wrote in message
news:10*************@corp.supernews.com...
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.


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

Jul 17 '05 #3

P: n/a
Thanks everyone =)

"Tony Marston" <to**@NOSPAM.demon.co.uk> wrote in message
news:c4*******************@news.demon.co.uk...

"News" <ne**@news.com> wrote in message
news:10*************@corp.supernews.com...
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.


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

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.