Bob Stickel wrote:
>
> I have a database (aerial) and two tables (flights982 and master982) running
> under mysql Win32 and myodbc. Neither of these tables has a primary key
> field. I would like to alter the tables to make a field name "id" as the
> primary key with auto_increment enabled. here is what I tried:
>
> mysql> use aerial
> database changed
>
> mysql> alter table flights982,
> -> insert into table flights982,
> -> id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
> -> PRIMARY KEY (id);
>
> I get a parse error for line 2 so my syntax must be wrong but I can't
> figure what I'm doing wrong. I didn't know whether or not to drop the data
> from the table to do this operation...
>
> Thanks
>
> Bob
Hi Bob
There is no 'INSERT INTO' allowed in the ALTER TABLE syntax.
What you search for is:
ALTER TABLE
flights982
ADD
id TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY
Tschau
Christian