Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Increasing Field Length 1

Status
Not open for further replies.

ddansie

Technical User
Nov 19, 2002
13
0
0
US
I am a really NEW person with MySQL. I need to increase a field length in a table that I created. Can someone please tell me how to do this. Please remember I am really new in this, so the answer will need to be very simple and straight forward.
Thanks for your help
 
What type of field is the original field? ______________________________________________________________________
TANSTAAFL!
 
the field is a varchar(20) null and I want to increase it to varchar(30) not null.
 
Assuming table is named "foo" and your column is named "bar":

ALTER TABLE foo MODIFY bar varchar(30) not null;

should do it. ______________________________________________________________________
TANSTAAFL!
 
Thank you for your help.... I was able to change it. one more question if you don't mind. I have a "Notes" field varchar(100) null, what is the largest size I can make that field? Can I increase the size to 250 or 300?
Once again thanks for your help

-Dale
 
The longest a varchar can be is 255 bytes. To store more than that, you need to use a column of type text. ______________________________________________________________________
TANSTAAFL!
 
Thank you....
So instead of using varchar(255) I can use text(300). So my statement would look like this:
ALTER TABLE foo MODIFY bar text(300) null;
 
That should work. ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top