i have an existing table with data say called "table10" and i want using code to add a column with an autoincrement (so on every insert the index will grow by 1 automaticlly) thnaks i nadvance peleg
ALTER TABLE table10 ADD COLUMN column_name INT(10 UNSIGNED NOT NULL AUTO_INCREMENT
Assuming you want it to be the primary key, then do:
ALTER TABLE table10 ADD PRIMARY KEY column_name
ALTER TABLE tbl_win ADD COLUMN id INT( 10 UNSIGNED NOT NULL AUTO_INCREMENT ) MySQL : #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 'UNSIGNED NOT NULL AUTO_INCREMENT)' at line 1
any idea why?
My bad, the closing parenthesis goes after the int(10), not the end of the entire expression.
Try this query to add a column id, auto_increment columns must be defined as key.
ALTER TABLE table_name ADD id INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;