bubblybabs Posted July 13, 2007 Share Posted July 13, 2007 I have a table named sentcards with a field called cardid with a current type int... I wish to change the type int to bigint(30) with an attribute that is unassisgned and a default of 0... This is my code: "ALTER TABLE ".$tablePrefix."sentcards MODIFY cardid cardid BIGINT(30) UNASSIGNED NOT NULL"; : but it doesn't work which makes me think I have something incorrect in my command... Could you point me in the right direction? Babs Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 Use this for reference: http://dev.mysql.com/doc/refman/5.0/en/alter-table.html Quote Link to comment Share on other sites More sharing options...
csplrj Posted July 13, 2007 Share Posted July 13, 2007 This query is for http://forum.mysql.com Anyway the query synatx can be found at http://dev.mysql.com/doc/refman/5.0/en/alter-table.html You can use the below command ALTER TABLE `dbname`.`tablename` MODIFY COLUMN `column` VARCHAR(255) Please add column Bye for now CSJakharia Quote Link to comment Share on other sites More sharing options...
bubblybabs Posted July 13, 2007 Author Share Posted July 13, 2007 Since this was asking for coding in php I figured this was the place to go... I changed the coding to this: "ALTER TABLE databasename gc_sentcards CHANGE cardid cardid BIGINT(30) UNASSIGNED NOT NULL default '0'"; but it still does not work... (databasename is changed from its correct info) That webpage states I don't need to use the word column but I tried it anyway: "ALTER TABLE databasename gc_sentcards CHANGE COLUMN cardid cardid BIGINT(30) UNASSIGNED NOT NULL default '0'"; Still not working... Should I go to this other forum to ask for assistance or stay here? Babs Quote Link to comment Share on other sites More sharing options...
csplrj Posted July 13, 2007 Share Posted July 13, 2007 You are using cardid twice Please check that out columnname is printed out twice Bye for now CSJakharia Quote Link to comment Share on other sites More sharing options...
jd2007 Posted July 13, 2007 Share Posted July 13, 2007 i did this: <?php $db = mysql_connect("localhost", "root"); $connection=mysql_select_db("Help", $db); $query = "ALTER TABLE sentcards MODIFY cardid bigint(30) not null"; $result=mysql_query($query); if ($result) { echo "Success !"; } else if (!$result) { echo "Failed !"; } else {} ?> notice that i removed unassigned and it showed 'success !' means it worked !, just replace the query in your script with this : $query = "ALTER TABLE sentcards MODIFY cardid bigint(30) not null"; tell me wheter it works or not.... if sql confuses u , go here http://www.techonthenet.com/sql/index.php... check this site too...www.w3schools.com Quote Link to comment Share on other sites More sharing options...
bubblybabs Posted July 13, 2007 Author Share Posted July 13, 2007 OK, removing unassigned allows this to work (as well as removing the extra cardid - I was following the instructions but mixed up what they meant)... But this must be unsigned or the mod I'm working on won't work... This worked for me thus far: "ALTER TABLE ".$tablePrefix."sentcards MODIFY cardid BIGINT(30) NOT NULL default '0'"; I'll look at the link you gave me, maybe it'll be clearer... I have to have it unsigned... And, looking at what I originally post I see I had a spelling error! It's unsigned not unassigned! Duh... Once I changed it to this it works: "ALTER TABLE ".$tablePrefix."sentcards MODIFY cardid BIGINT(30) UNSIGNED NOT NULL default '0'"; Thanks, I appreciate all of you helping me get this figured out... Babs Quote Link to comment 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.