Friday, September 20, 2013

IMPORTANT SQL QUERY

TO DELETE DUPLICATE RECORD FROM TABLE
IF TABLE TEST CONTAIN DUPLICATE RECORD


DELETE FROM TEST WHERE ROWID NOT IN 
(SELECT MIN(ROWID) FROM TEST GROUP BY ID)

##################################################


CREATE DUPLICATE TABLE WITH DATA USING ANOTHER TABLE


CREATE TABLE TEST AS SELECT * FROM TEST1;

########################################################


CREATE DUPLICATE TABLE SAME SCHEMA AS USING ANOTHER 

TABLE


CREATE TABLE TEST AS SELECT * FROM TEST1 WHERE 1=2;




No comments:

Post a Comment

About the Author : Anurag Pandey | Database cloud Architect | Oracle | SQL Server | PostgreSQL | AI and Data Platform Enthusiast

Anurag Pandey is a Database Architect with expertise in Oracle, PostgreSQL, SQL Server, Linux, and enterprise database platforms and specializes in database architecture, performance tuning, high availability, disaster recovery, cloud modernization, and operational excellence. With extensive experience in enterprise-scale environments, Anurag is passionate about leveraging AI, automation, and modern data platforms to improve reliability, scalability, and business outcomes. He actively contributes to technical communities through knowledge sharing, architecture guidance, and thought leadership in database and data engineering domains.

Follow more articles at

Visit Blog

Oracle 19c to PostgreSQL 15 Migration: Step-by-Step Production Guide (Ora2Pg + DMS)

Production-oriented migration approach for a complex Oracle 19c to PostgreSQL 15 workload , covering assessment, schema and code conversion,...