get columns number sql

Solutions on MaxInterview for get columns number sql by the best coders in the world

showing results for - "get columns number sql"
Laura
18 Aug 2017
1#With SQL
2
3SELECT count(*)
4FROM information_schema.columns
5WHERE table_name = 'Your_table_name';
6
Mía
21 Jan 2019
1//With JAVA
2
3String quer="SELECT * FROM sample2 where 1=2";
4
5Statement st=con.createStatement();
6ResultSet rs=st.executeQuery(quer);
7ResultSetMetaData rsmd = rs.getMetaData();
8int NumOfCol=0;
9NumOfCol=rsmd.getColumnCount();
10System.out.println("Query Executed!! No of Colm="+NumOfCol);
Nelia
12 Mar 2019
1SELECT TABLE_NAME , count(COLUMN_NAME)
2FROM information_schema.columns
3GROUP BY TABLE_NAME;
4
5-- Oracle (depending on schema grants):
6SELECT count(*) FROM USER_TAB_COLS WHERE TABLE_NAME = 'my_table';
7SELECT count(*) FROM ALL_TAB_COLS WHERE TABLE_NAME = 'my_table';
8SELECT count(*) FROM DBA_TAB_COLS WHERE TABLE_NAME = 'my_table';