sql number columns

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

showing results for - "sql number columns"
Logan
07 Jan 2017
1#With SQL
2
3SELECT count(*)
4FROM information_schema.columns
5WHERE table_name = 'Your_table_name';
6
Axel
13 Jan 2020
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);
Luis
08 Jan 2021
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';