您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

mysql如何快速删除重复的数据_MySQL

2024/3/18 6:40:16发布21次查看
在mysql中去重,其实是一个很简单的事情,来看下面的例子:
mysql> drop table test;query ok, 0 rows affected (0.01 sec)mysql> create table test(id int,name varchar(10));query ok, 0 rows affected (0.01 sec)mysql> insert into test values(1,'a1'),(2,'a2'),(3,'a3'),(4,'a4'),(1,'a1');query ok, 5 rows affected (0.00 sec)records: 5 duplicates: 0 warnings: 0mysql> select * from test;+------+------+| id | name |+------+------+| 1 | a1 || 2 | a2 || 3 | a3 || 4 | a4 || 1 | a1 |+------+------+5 rows in set (0.00 sec)mysql> alter ignore table test add unique index idx_id_name (id,name);query ok, 5 rows affected, 1 warning (0.02 sec)records: 5 duplicates: 1 warnings: 1mysql> show warnings;+---------+------+-----------------------------------------------------------------+| level | code | message |+---------+------+-----------------------------------------------------------------+| warning | 1681 | 'ignore' is deprecated and will be removed in a future release. |+---------+------+-----------------------------------------------------------------+1 row in set (0.00 sec)mysql> select * from test;+------+------+| id | name |+------+------+| 1 | a1 || 2 | a2 || 3 | a3 || 4 | a4 |+------+------+4 rows in set (0.00 sec)
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product