duplicate table postgresql code example

Example 1: postgres select duplicate columns

select Column1, Column2, count(*)
from yourTable
group by Column1, Column2
HAVING count(*) > 1

Example 2: postgres copy table from one schema to another

create table schema2.the_table (like schema1.the_table including all);
insert into schema2.the_table
select * 
from schema1.the_table;

Example 3: copy table postgres

CREATE TABLE new_table AS 
TABLE existing_table;

Example 4: postgres select duplicate columns

select * from yourTable ou
where (select count(*) from yourTable inr
where inr.sid = ou.sid) > 1

Tags:

Sql Example