PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

oracle怎么查询多少列

WBOY
WBOY 原创
2022-06-10 16:32:49 5546浏览

在oracle中,可以利用select语句配合“count(*)”查询表中有多少列,语法为“select count(*) from user_tab_cols where table_name='表名'”;“user_tab_cols”还可以用于查询隐藏列,并且表名中的英文应该使用大写字母。

本教程操作环境:windows10系统、Oracle 12c版、Dell G3电脑。

oracle怎么查询多少列

oracle查询多少列:

select count(*) from user_tab_cols where table_name='表名';

--表名含英文的话应为英文大写字母

示例如下:

28.png

29.png

扩展知识:

Oracle中user_tab_cols、user_tab_columns的差异

两表均可用于查询用户下Table(表)、View(视图)、Clusters(聚簇表)

差异

-- 通过执行此SQL语句,可发现user_tab_cols还包含隐藏列,因此平时使用时推荐使用user_tab_columns
select column_name from user_tab_cols where table_name = 'TEST'
minus
select column_name from user_tab_columns where table_name = 'TEST';

通过与user_tab_comments(表注释)、user_col_comments(字段注释)搭配使用,可基本满足一般统计需求

mysql查询多少列:

select count(*) from information_schema.COLUMNS where table_name='表名';

--表名大小写均可

sqlserver查询多少列:

select count(*) from syscolumns s  where s.id = object_id('test');

--表名大小写均可

推荐教程:《Oracle视频教程

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。