统计Oracle中表的数量
就像MySQL有“SHOW TABLES”一样,如何对Oracle DB中的表进行计数。一点点的研究给了我这样的疑问:
select owner, count(*) from dba_tables
那么就像 MySQL 有一个标准命令一样,Oracle 有一个吗?
Like MySQL has "SHOW TABLES" , how do you count tables in Oracle DB. Little bit of research gave me this query:
select owner, count(*) from dba_tables
So like MySQL has a standard command, does Oracle have one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
尝试:
在撰写本文时运行 mysql(OP 注释), 这个网站非常适合测试各种数据库类型。
try:
at the time of writing, this site was great for testing on a variety of database types.
是的,您的查询肯定会起作用,只需稍微修改一下即可。请参阅此处:http://download. oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2105.htm#i1592091
运行此命令:
获取表列表。
并运行此命令:
以获取表的数量。
Yeah sure your query will work just modify it a little. Look here for refrence : http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2105.htm#i1592091
Run this:
to get list of tables.
and Run this:
to get the count of tables.
请在下面找到 - 这是我使用的最简单的一种:
Please find below - its the simplest one I use :
这些文档描述了数据字典视图:
all_tables: http:// docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_4473.htm#REFRN26286
user_tables:http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_2105.htm#i1592091
dba_tables: http://docs.oracle.com/cd/B19306_01/server.102/ b14237/statviews_4155.htm#i1627762
您可以对这些视图运行查询来计算您需要的内容。
在@Anurag Thakre 的回答中添加更多内容:
或表所有者:
表空间本身并不标识唯一的对象所有者。多个用户可以在同一个表空间中创建对象,单个用户可以在不同的表空间中创建对象。
将表和索引分离到不同的表空间中是一种常见的做法。
These documents describe data dictionary views:
all_tables: http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_4473.htm#REFRN26286
user_tables: http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_2105.htm#i1592091
dba_tables: http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_4155.htm#i1627762
You can run queries on these views to count what you need.
To add something more to @Anurag Thakre's answer:
Or by table owners:
Tablespace itself does not identify an unique object owner. Multiple users can create objects in the same tablespace and a single user can create objects in various tablespaces.
It is a common practice to separate tables and indexes into different tablespaces.
如果您想要所有者列表以及每个所有者的表数量,请尝试:
If you'd like a list of owners, and the count of the number of tables per owner, try:
如果你想知道属于某个模式/用户的表的数量,你也可以使用类似于以下的 SQL:
If you want to know the number of tables that belong to a certain schema/user, you can also use SQL similar to this one:
使用此查询将为您提供有关表所有者的实际计数
Use this query which will give you the actual no of counts in respect to the table owners
……
.....
此查询将查找特定模式中的所有对象计数
THIS QUERY WILL FIND ALL THE OBJECTS COUNTS IN A SPECIFIC SCHEMA