在oracle中,可以利用select語句配合“count(*)”查詢表中有多少列,語法為“select count(*) from user_tab_cols where table_name='表名'”;“user_tab_cols”還可以用于查詢隱藏列,并且表名中的英文應(yīng)該使用大寫字母。
本教程操作環(huán)境:windows10系統(tǒng)、Oracle 12c版、Dell G3電腦。
oracle怎么查詢多少列
oracle查詢多少列:
select count(*) from user_tab_cols where table_name='表名';
–表名含英文的話應(yīng)為英文大寫字母
示例如下:
擴(kuò)展知識:
Oracle中user_tab_cols、user_tab_columns的差異
兩表均可用于查詢用戶下Table(表)、View(視圖)、Clusters(聚簇表)
差異
-- 通過執(zhí)行此SQL語句,可發(fā)現(xiàn)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(字段注釋)搭配使用,可基本滿足一般統(tǒng)計需求
mysql查詢多少列:
select count(*) from information_schema.COLUMNS where table_name='表名';
–表名大小寫均可
sqlserver查詢多少列:
select count(*) from syscolumns s where s.id = object_id('test');
–表名大小寫均可
推薦教程:《Oracle視頻教程》