Find total number of rows in DB2 table
Hi
Iam new to DB2, how do i find total number of rows in DB2 table, select a row using indexes in DB2?
Thanks
Â
Hi
Iam new to DB2, how do i find total number of rows in DB2 table, select a row using indexes in DB2?
Thanks
Â
Â
Hello,
You can use SELECT COUNT(*) FROM <table_name> in your DB2 query.
If your table is huge enough, SELECT COUNT(*) may not be desirable.
The SYSIBM.SYSTABLES catalog table has this column. The column mentioned here is updatable. Just in case there is ongoing transaction against the table, the value return might not be accurate. The value is negative one (-1) for this query if the database is not yet done gathering all the rows on the table.
Of course you can select using indexed column. All you have to do is, specify it on the WHERE clause of the query.
I hope it helped.