简体   繁体   English

Oracle中带有TABLE_NAME和NUMBER_COLUMNS列的表

[英]Table with columns TABLE_NAME and NUMBER_COLUMNS in Oracle

I am working with an Oracle database that has a number of tables. 我正在使用具有许多表的Oracle数据库。 I am being asked to generate a table with metadata about these tables, more precisely, I need a table with columns TABLE_NAME (where each row shows the name of a table) and NUMBER_COLUMNS (where each row shows the number of columns in that table). 我被要求生成一个包含有关这些表的元数据的表,更确切地说,我需要一个具有TABLE_NAME列(其中每一行显示表名)和NUMBER_COLUMNS列(其中每一行显示该表中的列数)的表。

I am getting the info on the table names from ALL_TABLES but I can't find a way to associate or even find the number of columns for each table. 我从ALL_TABLES获取有关表名的信息,但是我找不到一种方法来关联甚至找不到每个表的列数。 The methods that I've seen, like this one , only give me a row with the cumulative number of tables. 我所见过的方法(像这样 )只给了我一行表的累积数量。

Please help! 请帮忙!

You can do this: 你可以这样做:

select table_name, owner, count(*) as Number_Columns
from all_tab_cols
group by table_name, owner;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM