Home > Database > Oracle > How to query how many columns in oracle

How to query how many columns in oracle

WBOY
Release: 2022-06-10 16:32:49
Original
6164 people have browsed it

In Oracle, you can use the select statement with "count(*)" to query how many columns there are in the table. The syntax is "select count(*) from user_tab_cols where table_name='table name'"; "user_tab_cols" It can also be used to query hidden columns, and the English in the table name should use uppercase letters.

How to query how many columns in oracle

The operating environment of this tutorial: Windows 10 system, Oracle version 12c, Dell G3 computer.

How to query how many columns in oracle

How many columns to query in oracle:

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

--If the table name contains English, it should be English capital letters

Examples are as follows:

How to query how many columns in oracle

How to query how many columns in oracle

Extended knowledge:

The difference between user_tab_cols and user_tab_columns in Oracle

Both tables can be used to query Table, View and Clusters under the user

Difference

-- 通过执行此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';
Copy after login

By comparing with user_tab_comments (table comments), user_col_comments ( Field comments) can basically meet general statistical needs.

How many columns can be queried by mysql:

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

--The table name can be both uppercase and lowercase

How many columns can be queried by sqlserver:

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

--Table names can be uppercase or lowercase

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to query how many columns in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template