Aug 8, 2006 #1 altendew Programmer Mar 29, 2005 154 US Hi, I know its possible to count all the rows in a table by Code: SELECT COUNT(*) FROM table Is there anyway to count all the rows in a database? Thanks, Andrew
Hi, I know its possible to count all the rows in a table by Code: SELECT COUNT(*) FROM table Is there anyway to count all the rows in a database? Thanks, Andrew
Aug 8, 2006 #2 ClarkKent101 Programmer Jul 19, 2006 48 DE Hi Altendew, Try, SELECT COUNT(*) FROM table1, table2, table3 etc... ; That's the first method that comes to mind at the moment. Regards, - CK Upvote 0 Downvote
Hi Altendew, Try, SELECT COUNT(*) FROM table1, table2, table3 etc... ; That's the first method that comes to mind at the moment. Regards, - CK
Aug 8, 2006 Thread starter #3 altendew Programmer Mar 29, 2005 154 US Anyone else got any other methods? Thats a good idea though.. i have other 200 tables though Upvote 0 Downvote
Aug 8, 2006 1 #4 r937 Technical User Jun 30, 2002 8,847 CA actually, that's not a good idea at all, CK do a search for cross join after a couple of tables, your count will exceed a bazillion ;-) andrew, you could run a query to get all the table names, and use the output of that query to generate a whole series of count queries, one per table r937.com | rudy.ca Upvote 0 Downvote
actually, that's not a good idea at all, CK do a search for cross join after a couple of tables, your count will exceed a bazillion ;-) andrew, you could run a query to get all the table names, and use the output of that query to generate a whole series of count queries, one per table r937.com | rudy.ca
Aug 8, 2006 #5 Kozusnik Programmer Feb 27, 2005 620 Even easier. Use phpMyAdmin. Just choose which database you want and it shows total records, total size, and overhead (optimization time). I know size doesn't matter, but everyone runs out of disk sometime. Mark Upvote 0 Downvote
Even easier. Use phpMyAdmin. Just choose which database you want and it shows total records, total size, and overhead (optimization time). I know size doesn't matter, but everyone runs out of disk sometime. Mark
Aug 8, 2006 Thread starter #6 altendew Programmer Mar 29, 2005 154 US Sorry I needed this in a query. Upvote 0 Downvote
Aug 8, 2006 #7 Kozusnik Programmer Feb 27, 2005 620 Then r937's idea is the best. Mark Upvote 0 Downvote
Aug 8, 2006 #8 Kozusnik Programmer Feb 27, 2005 620 I found something... mysql -u <user> --password=<pass> <database> -e 'show table status;' | awk '{sum=sum+$5;} END {print sum}' Not quite a sql, but works well from a command line or within a program. Mark Upvote 0 Downvote
I found something... mysql -u <user> --password=<pass> <database> -e 'show table status;' | awk '{sum=sum+$5;} END {print sum}' Not quite a sql, but works well from a command line or within a program. Mark
Aug 9, 2006 #9 KarveR MIS Dec 14, 1999 2,065 GB You want it in a query for use with ? PHP? Shell? Perl? many ways to skin a cat, some done already. ______________________________________________________________________ There's no present like the time, they say. - Henry's Cat. Upvote 0 Downvote
You want it in a query for use with ? PHP? Shell? Perl? many ways to skin a cat, some done already. ______________________________________________________________________ There's no present like the time, they say. - Henry's Cat.
Aug 9, 2006 Thread starter #10 altendew Programmer Mar 29, 2005 154 US Well I could create it.. I just didnt know if there is a way to-do it in one query. (PHP) Thanks. Upvote 0 Downvote
Aug 9, 2006 #11 KarveR MIS Dec 14, 1999 2,065 GB it takes a few in PHP, but the funtions are there to make it easy. see mysql_list_dbs() # returns a list of dbs, loop through each calling mysql_list_tables(db) and loop through and count records. takes a couple of lines of code but alot more to make it look pretty ______________________________________________________________________ There's no present like the time, they say. - Henry's Cat. Upvote 0 Downvote
it takes a few in PHP, but the funtions are there to make it easy. see mysql_list_dbs() # returns a list of dbs, loop through each calling mysql_list_tables(db) and loop through and count records. takes a couple of lines of code but alot more to make it look pretty ______________________________________________________________________ There's no present like the time, they say. - Henry's Cat.