[SOLVED] Code for ALTER TABLE

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

[SOLVED] Code for ALTER TABLE

Post by tstimple »

Can somone tell me what the syntax is for using an ALTER TABLE command to set a mySQL column type to be BINARY?

Can you do it the same way you set a type to be an INTEGER, for example...

If the column field name is column1,

I've tried:
"ALTER TABLE CHANGE column1 column1 BINARY"

Doesn't seem to wotk

thanks,

--Tim
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

"ALTER TABLE `[table_name]` CHANGE `[current_field_name]` `[new_field_name]` [new_type]( [new_length/value] ) BINARY";

For Example:

Code: Select all

ALTER TABLE `cache` CHANGE `mod_title` `mod_title2` VARCHAR( 30 ) BINARY NOT NULL
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

Post by tstimple »

Thanks,

I did not know I had to declare the number of characters and NULL or NOT NULL.

Works Great now

Thanks Again,

--Tim
Post Reply