---
title: "oracle 查询有数据的表，以及统计数据不一致时的解决方法"
author: "paper"
date: "2012-12-24T15:56:07Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2012-12-24T16:02:01Z"
id: 1753152
url: "https://paper.iteye.com/blog/1753152"
---

查询有数据的表

 

 

SELECT table\_name, nvl(num\_rows,1)

FROM dba\_tables t where t.owner = 'username'order by nvl(num\_rows,1) desc

 

如果跟select count(\*) from tablename 的值不一样，在命令行执行以下存储过程

 EXEC dbms\_stats.gather\_schema\_stats(ownname=&gt;'own username');