aspose file tools*
The moose likes JDBC and the fly likes How to obtain a database table size? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to obtain a database table size?" Watch "How to obtain a database table size?" New topic
Author

How to obtain a database table size?

Tsehau Chao
Greenhorn

Joined: Jul 20, 2008
Posts: 6
Hi, I'm not sure what to look for, so any pointers appreciated.

So far I've succeeded to connect to a MySQL database and insert data inside. What I'm trying to do next is to the verify that the new data actually made it to the DB, and then remove the old data from the DB.

I think I can do this by comparing the table size, but how does one obtain a certain table size? Which API should I be looking for? Thanks in advance!
Rajah Nagur
Ranch Hand

Joined: Nov 06, 2002
Posts: 239
You can use the SQL Select to verify whether the new data has been inserted.

Getting table size using SQL is tricky and I'm not sure how reliable it is.
Also for your problem, SQL select would suffice.

To cut a blade of grass, your nails (SQL Select) are sufficient, axe (Table size) is an overkill option.


You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>
Manish Singh
Ranch Hand

Joined: Jan 26, 2007
Posts: 160
Most of the database returns the number of rows updated by the last statement.
You can use that to find out your operation was successful or nut.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

"select count(*) from table" gives you the number of rows. I think you mean number of rows and not actual number of bytes in the table.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Tsehau Chao
Greenhorn

Joined: Jul 20, 2008
Posts: 6
Thanks for all the kind replies. I'll try to work them out! (Jeanne you're right, that IS what I mean!)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to obtain a database table size?