natnat Posted July 4, 2006 Share Posted July 4, 2006 I am trying to find the syntax used to chnge a datatype. The reason why is because i had a datatype that is only to allow up to 5 numbers to be entered. the datatype i used is varchar(5). when I test it, if more than 5 numbers are entered, it takes them anyway and just truncates the numbers entered after the 1st five.I'm thinking that if I change my datatype to int(5) instead, that will correct the problem. Am i right? and if so.. does anyone know the correct syntax to change it, or where i can find it? Link to comment Share on other sites More sharing options...
aspnetguy Posted July 4, 2006 Share Posted July 4, 2006 actually it is INT(4) by default. That doesn't limit it to 4 characters (actually I do not know the limit of INT but the best way is to limit the user input on the application interface. Link to comment Share on other sites More sharing options...
natnat Posted July 4, 2006 Author Share Posted July 4, 2006 how would I do that?I am doing everything from the command prompt so I dont have an interface I'm looking at or using.do you mean that I need to write some sort of code that says..if char entered over 5 numbers, write error message..?something like that? Link to comment Share on other sites More sharing options...
aspnetguy Posted July 4, 2006 Share Posted July 4, 2006 oh, I have no idea how to do that in command line.I think VARCHAR is your best bet even though it truncates. Are you just testing or is the this going to be a program that makes users use command line? Link to comment Share on other sites More sharing options...
natnat Posted July 4, 2006 Author Share Posted July 4, 2006 just testing..so I'm pretty sure if I do use this for production, the final product will have a GUI and its probably going to be webbased for our company's intranet which I to be honest dont know how to do exactly Link to comment Share on other sites More sharing options...
aspnetguy Posted July 4, 2006 Share Posted July 4, 2006 you will want to look into XHTML/CSS and maybe JavaScript. Also in order to interact with the database you will need a server side language like PHP or ASP.Net Link to comment Share on other sites More sharing options...
natnat Posted July 4, 2006 Author Share Posted July 4, 2006 okI'm researching those things now. I guess I'll have to see what happens when I finish the general sql queries and incorporate it to something else. wish me luck!! Link to comment Share on other sites More sharing options...
zanfranceschi Posted July 6, 2006 Share Posted July 6, 2006 the query to alter a column is: ALTER TABLE `mytable` CHANGE `uuu` `uuu` TINYINT( 5 ) change the type as you want Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now