查询表中是否有主键、删除重复数据

1、查询表是否有主键
select cu.* from user_cons_columns cu, user_constraints au where
cu.constraint_name = au.constraint_name and au.constraint_type = 'P' and
au.table_name = '表明'

2、删除重复数据

delete from 表名 s  where 字段  in
(select 字段 from 表名 group by 字段 having count(字段)>1)
  and ROWID   IN (select min(rowid) from 表名 GROUP BY 字段 HAVING COUNT(*) > 1) 

你可能感兴趣的:(学习总结)