database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Q&A 3000 게시물 읽기
No. 3000
Delete duplicate records in a table
작성자
정재익
작성일
2001-06-22 07:57
조회수
1,910

Submitted on: 03-16-2001

Description:

Delete duplicate records in a table

Code:

 

This is a fast way to find duplicate records in a table and delete them.

 

Note: Replace the various table and field names with yours.

 

Example:

--

-- Create a function which will return the max OID from a table

-- based on the unique id. In this case, it is hash

--

create function maxoidhash( int8)

returns int as

'select max(oid) from codes where hash = $1'

language 'sql';

--

-- Now delete

--

delete from codes where oid < maxoidhash(hash) ;

 

--

-- Drop the function

--

drop function maxoidhash;

[Top]
No.
제목
작성자
작성일
조회
3003Number of affected rows
정재익
2001-06-22
1931
3002eval() for PostgreSQL
정재익
2001-06-22
1959
3001Retrive comma separated PK attributes
정재익
2001-06-22
1906
3000Delete duplicate records in a table
정재익
2001-06-22
1910
2999Error catching
정재익
2001-06-21
1836
2998Operator --- IMP (&gt;&gt;&gt; operator as logical implication)
정재익
2001-06-21
1804
2997Aggregate Function (2) -- first(), last()
정재익
2001-06-21
1733
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.021초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다