TheLostGuru Posted June 12, 2007 Share Posted June 12, 2007 Is it possible to change a table in a database without just dropping it and recreating it. As example, I have a photo column which stores an URL, but it seems to only be accepting about 25 characters. Is there a way I can update the table without starting it over? Also, when I made the photo column I think I put, photo varchar(25), is there any reason I don't want to make it like varchar(1000), although I know that varchar only accepts 255, so what do I change varchar to? Quote Link to comment https://forums.phpfreaks.com/topic/55335-changing-a-database-table/ Share on other sites More sharing options...
Julian Posted June 12, 2007 Share Posted June 12, 2007 Hi If you use varchar you can only add 255. If you want to use more character use BLOB instead. Also, if you want to change the current table use the MySQL: ALTER TABLE Quote Link to comment https://forums.phpfreaks.com/topic/55335-changing-a-database-table/#findComment-273523 Share on other sites More sharing options...
pocobueno1388 Posted June 12, 2007 Share Posted June 12, 2007 Just go into your database, and you should be able to change the field types from there without disrupting anything in the table...unless there is already something inserted into the table that your new field type won't be compatible with. I would probably change the varchar to a TEXT or BLOB type. Quote Link to comment https://forums.phpfreaks.com/topic/55335-changing-a-database-table/#findComment-273524 Share on other sites More sharing options...
TheLostGuru Posted June 12, 2007 Author Share Posted June 12, 2007 How does the alter table work? Also what's the difference between TEXT, BLOB, and varchar? Quote Link to comment https://forums.phpfreaks.com/topic/55335-changing-a-database-table/#findComment-273530 Share on other sites More sharing options...
Julian Posted June 12, 2007 Share Posted June 12, 2007 Check this out: http://dev.mysql.com/doc/refman/5.0/en/char.html You use alter table command to change current table settings: e.g.: ALTER TABLE `TBL_NAME` CHANGE `FIELD` `FIELD` varchar(100) NOT NULL DEFAULT "Standard" Quote Link to comment https://forums.phpfreaks.com/topic/55335-changing-a-database-table/#findComment-273531 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.