站长资讯网
最全最丰富的资讯网站

oracle怎么查询多少列

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

oracle怎么查询多少列

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

oracle怎么查询多少列

oracle查询多少列:

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

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

示例如下:

oracle怎么查询多少列

oracle怎么查询多少列

扩展知识:

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视频教程》

赞(0)
分享到: 更多 (0)