Find total number of rows in DB2 table

Asked By 0 points N/A Posted on -
qa-featured

Hi

Iam new to DB2, how do i find total number of rows in DB2 table, select a row using indexes in DB2?

Thanks

 

SHARE
Answered By 0 points N/A #108492

Find total number of rows in DB2 table

qa-featured

 

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.

Login/Register to Answer

Related Questions