Professional Web Applications Themes

alter table alter column syntax problem - MySQL

I am trying to set the cht and collation for all of my database table columns to Collation - latin1_general_ci When I try to execute the following Query (using Php mysql_query()) I get a syntax error "ALTER TABLE `table_name` ALTER COLUMN `column_name COLLATE latin1_general_ci" I get the following mysql error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLLATE latin1_general_ci' at line 1" I can't figure out what the problem is (the column is a varchar). Using MySQL 4.1.14 -- ***************************** Chuck Anderson ...

  1. #1

    Default alter table alter column syntax problem

    I am trying to set the cht and collation for all of my database
    table columns to
    Collation - latin1_general_ci

    When I try to execute the following Query (using Php mysql_query()) I
    get a syntax error

    "ALTER TABLE `table_name` ALTER COLUMN `column_name COLLATE
    latin1_general_ci"

    I get the following mysql error:

    "You have an error in your SQL syntax; check the manual that corresponds
    to your MySQL server version for the right syntax to use near 'COLLATE
    latin1_general_ci' at line 1"

    I can't figure out what the problem is (the column is a varchar).

    Using MySQL 4.1.14

    --
    *****************************
    Chuck Anderson • Boulder, CO
    http://www.CycleTourist.com
    *****************************
    Chuck Guest

  2. #2

    Default Re: alter table alter column syntax problem

    Chuck Anderson wrote: 

    The problem is your command is incorrect. Try:

    ALTER TABLE `table_name` CHANGE `column_name` COLLATE latin1_bin

    If that doesn't work, set all the attributes, i.e.

    ALTER TABLE `table_name` CHANGE `column_name` `column_name` VARCHAR(60)
    CHARACTER SET latin1 COLLATE latin1_bin NOT NULL

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

  3. #3

    Default Re: alter table alter column syntax problem

    Jerry Stuckle wrote: 
    >
    > The problem is your command is incorrect. Try:
    >
    > ALTER TABLE `table_name` CHANGE `column_name` COLLATE latin1_bin
    >
    > If that doesn't work, set all the attributes, i.e.
    >
    > ALTER TABLE `table_name` CHANGE `column_name` `column_name` VARCHAR(60)
    > CHARACTER SET latin1 COLLATE latin1_bin NOT NULL
    >
    >[/ref]
    Thanks.

    CHANGE with all the attributes is the only one that works.

    Annnnnnnd now ... reading a little closer (duh) I found CONVERT, which
    does exactly what I need to do. ALTER TABLE tbl_name CONVERT TO
    CHARACTER SET cht_name;

    (For anyone else reading this: There are some caveats, so be sure and
    read the manual.)


    --
    *****************************
    Chuck Anderson • Boulder, CO
    http://www.CycleTourist.com
    *****************************
    Chuck Guest

  4. #4

    Default Re: alter table alter column syntax problem

    On Mon, 04 Sep 2006 15:56:11 -0600, Chuck Anderson
    <sig> wrote:
     

    Looks like you're missing a backtick after column_name.

    Lee
    Lee Guest

  5. #5

    Default Re: alter table alter column syntax problem

    Lee Peedin wrote: 
    >
    > Looks like you're missing a backtick after column_name.
    >
    > Lee
    >[/ref]
    Thanks. That was not the problem, though, ... rather my own sloppy cut
    and paste.

    --
    *****************************
    Chuck Anderson Boulder, CO
    http://www.CycleTourist.com
    *****************************
    Chuck Guest

Similar Threads

  1. Alter table query problem
    By Jenny Rice in forum MySQL
    Replies: 3
    Last Post: June 8th, 08:16 AM
  2. Replies: 4
    Last Post: September 23rd, 01:53 AM
  3. alter a DMS table space
    By xixi in forum IBM DB2
    Replies: 0
    Last Post: August 4th, 09:18 PM
  4. Replies: 7
    Last Post: July 20th, 11:12 PM
  5. alter table/tables
    By Jacco Schalkwijk in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: July 11th, 08:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139