在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='表名';
–表名含英文的話應為英文大寫字母
示例如下:
擴展知識:
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視頻教程》
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦