It is possible to find the number of rows in a table:
select count(*) from tablename
Is it possible to find the number of columns in a tabl
db2 'describe table "SCHEMA_NAME"."TBL_NAME"'
Using JDBC in 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);
It is possible to find the number of columns in a table just by using 3 simple lines of PHP code.
$sql="SELECT * FROM table";
$query=mysqli_query($connect_dude,$sql);
$num=mysqli_num_fields($query);
$num
would return the number of columns
on a given table in this case.
Hopefully,it would help others.
SELECT COUNT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_CATALOG = 'database_name' AND TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'table_name'
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_catalog = 'database_name' -- the database
AND table_name = 'table_name'
Its been little late but please take it from me...
In the editor(New Query) by select the database object it can be a table too, if we use the Shortcut Key Alt+F1 we will get all the information of the object and I think will solve your problem as well.