[EP-tech] Re: MySQL query to update a column value
Robert Berry
robert.berry at liverpool.ac.uk
Thu Sep 20 11:57:02 BST 2012
Hi Claire,
Do not use the UPDATE statement. That's to alter records in the
database, not to change table structure.
You need to use ALTER TABLE (more info here:
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html).
The syntax you want will be something like,
ALTER TABLE `eprint` SET `type` VARCHAR(255);
(Change the number inside varchar to the maximum number of characters
you want to be stored in the field.)
If you're uncomfortable writing SQL statements yourself it might be
better to use some client software to perform operations like this. I
can't make any recommendations but Google 'MySQL client software' and
see what comes up.
Best wishes,
Robert Berry
Claire Eskriett <C.Eskriett at brighton.ac.uk> writes:
> Hi all
>
>
> Iâve edited eprints.pl to change the property of an eprint field from
> an integer to text but running update_database_structure has not
> updated the eprint table. Iâve been advised to update manually using
> MySQL and have come up with the following:
>
>
> Use <database name>
>
> Update eprint
>
> Set type = text
>
> Where field = num_pieces
>
>
> I think this is ok â Iâve specified the table (eprint) and the field
> that I want to update (num_pieces) and the column that I want updating
> is âtypeâ. The current row in the table is as follows:
>
> Field | Type | Null | Key | Default
> | Extra
>
> num_pieces | int(11) | YES | MUL | NULL | |
>
>
> Can anyone take pity on me and reassure me that this is ok? I ask as a
> MySQL novice.
>
>
> Many thanks for any advice!
>
>
> Claire
>
>
>
> Claire Eskriett, Systems Librarian
>
> (Days of work are Mon, Tues, Thurs & Fri)
>
> Information Services
>
> Cockcroft Building
>
> University of Brighton
>
> Lewes Road
>
> Brighton BN2 4GJ
>
> T: 01273 642766
>
> E: C.Eskriett at brighton.ac.uk
>
>
> ___________________________________________________________
> This email has been scanned by MessageLabs' Email Security
> System on behalf of the University of Brighton.
> For more information see http://www.brighton.ac.uk/is/spam/
> ___________________________________________________________
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/
More information about the Eprints-tech
mailing list