On 21-Mar-01 roger westin wrote:
> Hi I solved it my self.
> If anyone whats to know the awnser to this it was NOT as easy as the manual
> would have described.
> The only thing I got to work was:
> 1. Drop the index
> 2. create new field (whitout index and auto_inc) if any of them where added
> I got an error and nothing worked.
> 3. make the new one an index (got an error but after flushing the table it
> had made it an index anyway)
> 4. add the auto_inc.
> 

Huh ?

mysql> select * from tbl;
+-----+-------+
| oid | name  |
+-----+-------+
|   1 | bob   |
|   2 | vera  |
|   3 | steve |
|   4 | Mike  |
+-----+-------+
4 rows in set (0.62 sec)

mysql> alter table tbl drop primary key,drop oid;
Query OK, 4 rows affected (6.39 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> alter table tbl add id int not null auto_increment primary key first;
Query OK, 4 rows affected (3.06 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select * from tbl;
+----+-------+
| id | name  |
+----+-------+
|  5 | bob   |
|  6 | vera  |
|  7 | steve |
|  8 | Mike  |
+----+-------+
4 rows in set (0.39 sec)

mysql> alter table tbl drop primary key,drop id,
    -> add nid int auto_increment not null primary key first;
Query OK, 4 rows affected (3.87 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select * from tbl;
+-----+-------+
| nid | name  |
+-----+-------+
|   9 | bob   |
|  10 | vera  |
|  11 | steve |
|  12 | Mike  |
+-----+-------+
4 rows in set (0.35 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 3.23.33   |
+-----------+
1 row in set (0.09 sec)


-- 
Don Read                                         [EMAIL PROTECTED]
-- If you are going to sin, sin against God, not the bureaucracy. 
                  God will forgive you but the bureaucrats won't. 

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to