select @@version;
Microsoft SQL Server 2012 - 11.0.2218.0 (X64)
Jun 12 2012 13:05:25
Copyright (c) Microsoft Corporation
Enterprise Evaluation Edition (64-bit) on Windows NT 6.1 (Build
7601: Service Pack 1)
CREATE TABLE coolbid
(
ID INT UNIQUE
);
GO
INSERT INTO coolbid
VALUES (1),
(2),
(3);
GO
(3 row(s) affected)
INSERT INTO coolbid
VALUES (1);
GO
Msg 2627, Level 14, State 1, Line 2
Violation of UNIQUE KEY constraint 'UQ__coolbid__3214EC26654E5167'. Cannot
insert duplicate key in object 'dbo.coolbid'. The duplicate key value is (1).
The statement has been terminated.
SELECT * FROM coolbid;
1
2
3
UPDATE coolbid
set id = id + 1;
works in sql server.
indie=> select version();
version
----------------------------------------------------------------------------
---------------------------
PostgreSQL 9.1.6 on x86_64-unknown-linux-gnu, compiled by gcc-4.4.real (
Debian 4.4.5-8) 4.4.5, 64-bit
(1 row)
indie=> CREATE TABLE coolbid
indie-> (
indie(> ID INT UNIQUE
indie(> );
NOTICE: CREATE TABLE / UNIQUE will create implicit index "coolbid_id_key"
for table "coolbid"
CREATE TABLE
indie=>
indie=> INSERT INTO coolbid
indie-> VALUES (1),
indie-> (2),
indie-> (3);
INSERT 0 3
indie=>
indie=> INSERT INTO coolbid
indie-> VALUES (1);
ERROR: duplicate key value violates unique constraint "coolbid_id_key"
DETAIL: Key (id)=(1) already exists.
indie=>
indie=> SELECT * FROM coolbid;
id
----
1
2
3
(3 rows)
indie=>
indie=> UPDATE coolbid
indie-> set id = id + 1;
ERROR: duplicate key value violates unique constraint "coolbid_id_key"
DETAIL: Key (id)=(2) already exists.
doesnt work in postgres.
thanks for the posting. I learned something new today.