Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 ALTER table

Author  Topic 

CM670
Starting Member

2 Posts

Posted - 2013-01-21 : 06:31:53
Hi,
I have already created a table and forgot to add in the first row.
This row should auto-increment, be unique and of type int.

I have tried using this statement but i keep getting a syntax error.


alter table 'comp_table'
add column 'comp_id' int null auto_increment unique first;

Can anyone tell me what i am doing wrong?

Thanks.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-01-21 : 06:45:57
Here we are on MS SQL Server only. Your syntax doesn't look like MS SQL Server. What is it?


Too old to Rock'n'Roll too young to die.
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-01-21 : 06:48:10
This is the syntax in Sql Server...
ALTER TABLE tableName ADD colName int NOT null
identity(1,1) unique


I think yours is MySql. ( auto incremented column should be not null)
ALTER TABLE 'table_name' ADD COLUMN 'id' INTEGER NOT NULL AUTO_INCREMENT FIRST

Post your MySql related queries in www.dbforums.com


--
Chandu
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2013-01-21 : 10:25:23
http://forums.mysql.com/ is also a good mysql forum

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -