copying a column

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

    copying a column

    I'm learning how to copy columns and I'm having a little trouble.
    The column that I'm trying to copy is from the same database. Correct
    me if I am wrong, but I think you have to create the column in the
    database first? Here is the command that I'm using, but its not
    working, obviously.

    mysql> alter table bugs add column test mediumint(9) NOT NULL
    auto_increment;
    ERROR 1075 (42000): Incorrect table definition; there can be only one
    auto column and it must be defined as a key

    Here is the table that has the column that I'm trying to copy from:

    mysql> describe bugs \G
    *************** ************ 1. row *************** ************
    Field: bug_id
    Type: mediumint(9)
    Null:
    Key: PRI
    Default: NULL
    Extra: auto_increment

    Can somebody give me a clue. Also, I'm looking for detailed
    documentation on primary keys, if somebody has such a link, please send
    it to me, thanks in advance.

    usaims

  • Felix Geerinckx

    #2
    Re: copying a column

    On 14/06/2005, usaims wrote:
    [color=blue]
    > I'm learning how to copy columns and I'm having a little trouble.
    > The column that I'm trying to copy is from the same database. Correct
    > me if I am wrong, but I think you have to create the column in the
    > database first?[/color]

    You don't create columns in a database, but in a table (which lives in
    a database)
    [color=blue]
    > Here is the command that I'm using, but its not
    > working, obviously.
    >
    > mysql> alter table bugs add column test mediumint(9) NOT NULL
    > auto_increment;
    > ERROR 1075 (42000): Incorrect table definition; there can be only one
    > auto column and it must be defined as a key
    >
    > Here is the table that has the column that I'm trying to copy from:
    >
    > mysql> describe bugs \G
    > *************** ************ 1. row *************** ************
    > Field: bug_id
    > Type: mediumint(9)
    > Null:
    > Key: PRI
    > Default: NULL
    > Extra: auto_increment
    >
    > Can somebody give me a clue.[/color]

    You already have an auto_increment column in your table and you only
    can have one: so you cannot add another
    [color=blue]
    > Also, I'm looking for detailed
    > documentation on primary keys, if somebody has such a link, please
    > send it to me, thanks in advance.[/color]

    Type 'primary key' in a google search box.

    --
    felix

    Comment

    Working...