欢迎来到Oracle世界。
您使用的声明 analyze table tablename compute statistics 不会帮到你。此命令用于计算查询优化器使用的Oracle DB内部统计信息,因此Oracle可以找到查询数据的最佳方法(有关更多信息,请参阅 基于成本的优化工具 )。此命令也已弃用,应使用dbms_stats 分析表,索引和群集
analyze table tablename compute statistics
现在让我们回答你的问题。它可以通过select中的子句来解决。见下面的例子:
create table foo_bar ( id_foo integer generated by default on null as identity , name_bar varchar2(100) , constraint Foo_Bar_PK primary key (id_foo) ); insert into foo_bar (name_bar) values ('John'); insert into foo_bar (name_bar) values ('John'); insert into foo_bar (name_bar) values ('Mike'); insert into foo_bar (name_bar) values ('Susan'); insert into foo_bar (name_bar) values ('Jerry'); insert into foo_bar (name_bar) values ('Jerry'); insert into foo_bar (name_bar) values ('Jerry'); -- query for all data select * from foo_bar; +--------+----------+ | ID_Foo | Name_bar | +--------+----------+ | 1 | John | | 2 | John | | 3 | Mike | | 4 | Susan | | 5 | Jerry | | 6 | Jerry | | 7 | Jerry | +--------+----------+ -- this query will return all names which have more than 1 occurrence in the table select name_bar from foo_bar group by name_bar having count(1)>1; +----------+ | name_bar | +----------+ | John | | Jerry | +----------+ --to get number of duplicate records you can use this select sum(count(name_bar)) from foo_bar group by name_bar having count(1)>1; drop table foo_bar;