Cannot change column name.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mick White

    Cannot change column name.

    I inadvertantly named a field "in"

    mysql> select * from guestbook;
    +----+-------+-------+-----------------+----------------+
    | id | fname | lname | comments | in |
    +----+-------+-------+-----------------+----------------+
    | 1 | Mick | White | Test 123 | 20050208000000 |
    | 2 | Ann | White | Hello World | 20050213101948 |
    | 3 | | | It's a nice day | 20050213102405 |
    +----+-------+-------+-----------------+----------------+
    mysql> select in from guestbook;
    ERROR 1064: 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 'in from guestbook' at line 1

    But I can't seem to be able to change it:
    mysql> alter guestbook change in time_in;
    ERROR 1064: 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 'guestbook change in time_in' at line 1

    The table:
    mysql> desc guestbook;
    +----------+-----------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +----------+-----------------+------+-----+---------+----------------+
    | id | int(4) unsigned | | PRI | NULL | auto_increment |
    | fname | varchar(10) | | PRI | | |
    | lname | varchar(10) | | | | |
    | comments | text | | | | |
    | in | timestamp(14) | YES | | NULL | |
    +----------+-----------------+------+-----+---------+----------------+

    Any takers?
    Mick
  • Jeff North

    #2
    Re: Cannot change column name.

    On Sun, 13 Feb 2005 18:56:29 GMT, in mailing.databas e.mysql Mick White
    <mwhite13BOGUS@ rochester.rr.co m> wrote:
    [color=blue]
    >| I inadvertantly named a field "in"
    >|
    >| mysql> select * from guestbook;
    >| +----+-------+-------+-----------------+----------------+
    >| | id | fname | lname | comments | in |
    >| +----+-------+-------+-----------------+----------------+
    >| | 1 | Mick | White | Test 123 | 20050208000000 |
    >| | 2 | Ann | White | Hello World | 20050213101948 |
    >| | 3 | | | It's a nice day | 20050213102405 |
    >| +----+-------+-------+-----------------+----------------+
    >| mysql> select in from guestbook;
    >| ERROR 1064: 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 'in from guestbook' at line 1
    >|
    >| But I can't seem to be able to change it:
    >| mysql> alter guestbook change in time_in;
    >| ERROR 1064: 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 'guestbook change in time_in' at line 1
    >|
    >| The table:
    >| mysql> desc guestbook;
    >| +----------+-----------------+------+-----+---------+----------------+
    >| | Field | Type | Null | Key | Default | Extra |
    >| +----------+-----------------+------+-----+---------+----------------+
    >| | id | int(4) unsigned | | PRI | NULL | auto_increment |
    >| | fname | varchar(10) | | PRI | | |
    >| | lname | varchar(10) | | | | |
    >| | comments | text | | | | |
    >| | in | timestamp(14) | YES | | NULL | |
    >| +----------+-----------------+------+-----+---------+----------------+
    >|[/color]

    ALTER TABLE `t2` CHANGE COLUMN `in` `time_in` TIMESTAMP(14);
    ---------------------------------------------------------------
    jnorthau@yourpa ntsyahoo.com.au : Remove your pants to reply
    ---------------------------------------------------------------

    Comment

    • Mick White

      #3
      Re: Cannot change column name.

      Jeff North wrote:

      [color=blue]
      >
      > ALTER TABLE `t2` CHANGE COLUMN `in` `time_in` TIMESTAMP(14);[/color]


      Thanks, Jeff, that did the trick.
      Mick

      Comment

      Working...