|
Home > Archive > MySQL Server Forum > June 2005 > copying a column
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| usaims 2005-06-14, 9:23 am |
| 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 2005-06-14, 9:23 am |
| On 14/06/2005, usaims wrote:
> 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?
You don't create columns in a database, but in a table (which lives in
a database)
> 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.
You already have an auto_increment column in your table and you only
can have one: so you cannot add another
> Also, I'm looking for detailed
> documentation on primary keys, if somebody has such a link, please
> send it to me, thanks in advance.
Type 'primary key' in a google search box.
--
felix
|
|
|
|
|