mysql>
create
table
t(id
int
unique
,
name
varchar
(4));
Query OK, 0
rows
affected (0.10 sec)
mysql>
insert
into
t
values
(1,
'python'
),(2,
'java'
);
Query OK, 2
rows
affected, 1 warning (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 1
mysql>
insert
into
t
values
(1,
'python'
),(2,
'java'
);
ERROR 1062 (23000): Duplicate entry
'1'
for
key
'id'
mysql>
create
table
t(id
int
unique
, ip
varchar
(12), port
varchar
(4),
unique
(ip, port));
Query OK, 0
rows
affected (0.01 sec)
mysql>
insert
into
t
values
(1,
'127.0.0.1'
,8080);
Query OK, 1 row affected (0.00 sec)
mysql>
insert
into
t
values
(2,
'127.0.0.1'
,8081);
Query OK, 1 row affected (0.00 sec)
mysql>
insert
into
t
values
(3,
'127.0.0.2'
,8080);
Query OK, 1 row affected (0.00 sec)
mysql>
insert
into
t
values
(4,
'127.0.0.1'
,8080);
ERROR 1062 (23000): Duplicate entry
'127.0.0.1-8080'
for
key
'ip'