Answers for "get columns number sql"

SQL
1

get columns number sql

#With SQL

SELECT count(*)
FROM information_schema.columns
WHERE table_name = 'Your_table_name';
Posted by: Guest on May-04-2021
1

get columns number sql

//With JAVA

String quer="SELECT * FROM sample2 where 1=2";

Statement st=con.createStatement();
ResultSet rs=st.executeQuery(quer);
ResultSetMetaData rsmd = rs.getMetaData();
int NumOfCol=0;
NumOfCol=rsmd.getColumnCount();
System.out.println("Query Executed!! No of Colm="+NumOfCol);
Posted by: Guest on May-04-2021
4

get number of columns sql

SELECT TABLE_NAME , count(COLUMN_NAME)
FROM information_schema.columns
GROUP BY TABLE_NAME;

-- Oracle (depending on schema grants):
SELECT count(*) FROM USER_TAB_COLS WHERE TABLE_NAME = 'my_table';
SELECT count(*) FROM ALL_TAB_COLS WHERE TABLE_NAME = 'my_table';
SELECT count(*) FROM DBA_TAB_COLS WHERE TABLE_NAME = 'my_table';
Posted by: Guest on April-20-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language