How do you find the number of rows in a table?

Questions by bsush

Showing Answers 1 - 29 of 29 Answers

Mohammad Damati

  • Oct 19th, 2006
 

upon the data base type,

in SQL i think just Count(*)

but in ACCESS it is not allowed to count(*) so we have to make a loop !!!

WHILE NOT RS.EOF

  Was this answer useful?  Yes

JOJIPOGI

  • Oct 21st, 2006
 

you can also use select sum(1) from tablename

  Was this answer useful?  Yes

james bond007

  • Oct 24th, 2006
 

Well, there are various ways through which you can get the number of rows from the oracle database.

1. select * from tablename; will return all data and number of rows

2. select count(*) from tablename;

3. select sum(1) from tablename;

first two are very much handy to use and third one is dependent on the situation because sum function is for arithmatic operations.

  Was this answer useful?  Yes

Mark

  • Dec 2nd, 2006
 

exec sp_spaceused 'table_name';

select rows from sysindexes where name = object_name(id) and indid in (0,1);

  Was this answer useful?  Yes

raj

  • Dec 17th, 2006
 

hi all..

pls tell me the query to find out the no.of columns in a table ?

  Was this answer useful?  Yes

Rajneesh Kaur

  • Dec 21st, 2006
 

Number of rows can be found by:SELECT COUNT(*) FROM TABLENAME;Number of columns can be found by:SELECT COUNT(*) FROM DBA_TAB_COULUMNSWHERE TABLENAME="TABLE_NAME";

  Was this answer useful?  Yes

manohar

  • Feb 6th, 2007
 

Select count(*) from TAB_NAME;

  Was this answer useful?  Yes

Hi,

We have one UnDocumented Stored Procedure sp_MSforeachtable in SQL Server.

Create Table #TEMPs(TBLName Varchar(128),RowC Int)
exec sp_MSforeachtable 'Insert #TEMPs select ''?'', count(*) from ?' 
select * from #TEMPs Order By RowC Desc
drop table #TEMPs

The above lines of code returns Each Tablename with It's RowCount for all tables in the current DataBase.

Pandian S

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions