Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Change column type: VARCHAR to SMALLINT

Quote Reply
Change column type: VARCHAR to SMALLINT
Hi

due to an oversight when designing my site I set one of the column types to VARCHAR, I should really have set this as one of the INT types as the column is for a 'numerical value'

After 1 year of running the site, the situation has arisen when I wanted to search the database using this column for values above 'xx'

This option is not available, as the filed was set to VARCHAR

Is it ok / safe to change the column in the LINKS table from VARCHAR to SMALLINT?

Thanks
Colin Thompson
Quote Reply
Re: [colintho] Change column type: VARCHAR to SMALLINT In reply to
Sure, although may be better with an INT (not sure how large the numbers you have are gonna get)

Also, make sure they don't have commas etc in (i.e they are ONLY numerical).

Just to be on the safe side, I'd do a full backup of your database too (doing via phpMyAdmin would be better, as recently I've had a ton of issues with MySQLMan, where it dosn't setup DEFAULT values right (for stuff that doesn't need a value), and causes all kinda headaches when re-importing it.

Either that, or if you have SSH, use mysqldump:

mysqldump --add-drop-table -uUSER -pPASS DB_NAME > backup.sql

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Change column type: VARCHAR to SMALLINT In reply to
Thanks Andy

would values like this be OK? 49.95
Colin Thompson
Quote Reply
Re: [colintho] Change column type: VARCHAR to SMALLINT In reply to
You may be better with a FLOAT, as thats designed for decimals.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Change column type: VARCHAR to SMALLINT In reply to
Thanks

just to confirm that this will allow me to do a search of the Links Table, for links that are: Greater Than or Less Than from GLinks admin?

Thanks
Colin Thompson
Quote Reply
Re: [colintho] Change column type: VARCHAR to SMALLINT In reply to
Yeah.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!