如何用SQL计算一个表中的列数? 您所在的位置:网站首页 sql计算列使用方法 如何用SQL计算一个表中的列数?

如何用SQL计算一个表中的列数?

2024-05-24 21:00| 来源: 网络整理| 查看: 265

问题描述 本文来自:IT宝库(https://www.itbaoku.cn)

如何使用SQL计数表中的列数?

我正在使用Oracle 11G

请帮忙. t.

推荐答案 select count(*) from user_tab_columns where table_name='MYTABLE' --use upper case

而不是大写,您可以使用较低的功能. 前任: 从user_tab_columns中选择计数(*),其中serve(table_name)='table_name';

其他推荐答案

也许是这样的东西:

SELECT count(*) FROM user_tab_columns WHERE table_name = 'FOO'

这将计算一个表中的列数

您也可以只是

select count(*) from all_tab_columns where owner='BAR' and table_name='FOO';

所有者是架构的地方,请注意表格名称是上情况

其他推荐答案

旧问题 - 但是我最近需要与行计数一起使用...这是对两者的查询 - 由行计数排序desc:

SELECT t.owner, t.table_name, t.num_rows, Count(*) FROM all_tables t LEFT JOIN all_tab_columns c ON t.table_name = c.table_name WHERE num_rows IS NOT NULL GROUP BY t.owner, t.table_name, t.num_rows ORDER BY t.num_rows DESC;

本文地址:https://www.itbaoku.cn/post/1712496/How-to-count-the-number-of-columns-in-a-table-using-SQL



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有