SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question getting size in k of table

    hello

    can someone tell me is there a query i can use to get the size in k or bytes of a table in my database, i notice that in phpmyadmin there is the size of the table marked so i presume this is possible??

    a+
    gar

  2. #2
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SHOW TABLE STATUS FROM database

    this will give you all the info for all tables you just have to split it up
    the neigbours (free) WIFI makes it just a little more fun

  3. #3
    Action! filmfoto's Avatar
    Join Date
    Dec 2001
    Location
    Sweden
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The easy way is to use phpMyAdmin. All tables are presented with total rows and size.

    Or customize this simple script to your liking:
    PHP Code:
    <?php
    mysql_connect
    ("host""user""pass")
        or die(
    "The site database appears to be down.");


    if (!
    mysql_select_db("db"))
        die(
    "The site database is unavailable.");

    $result mysql_query("show table status");

    if (
    $result) {
        echo (
    "<table><tr><th>Table</th><th>Size</th></tr>");
        while (
    $row mysql_fetch_array($result)) {
            
    $name $row["Name"];
            
    $size $row["Data_length"];
            echo(
    "<tr><td>$name</td><td>$size</td></tr>\n");
        }
        echo (
    "</table>");
    } else {
        echo (
    "Query error!");
    }
    ?>
    Hope this helps.




    Cheers.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •