You can get information about tables using SHOW
TABLE STATUS query. This query gives you a detailed info about all
tables in your database. Code sample will show you find next Autoindex
in selected table.
Displaying mySQL table structures in PHP
You can get information about tables using SHOW TABLE STATUS query.
This query gives you a detailed info about all tables in your database.
We can loop results:
- Name
- Engine
- Version
- Row_format
- Rows
- Avg_row_length
- Data_length
- Max_data_length
- Index_length
- Data_free
- Auto_increment
- Create_time
- Update_time
- Check_time
- Collation
- Checksum
- Create_options
- Comment
We can re-write this query to find only structure about a tables:
SHOW TABLE STATUS LIKE ’products’
If you wish to learn AutoIndex number, here's the comple code written in PHP:
<?php
$qquery = mysql_query("SHOW TABLE STATUS LIKE 'products'");
$row = mysql_fetch_assoc($qquery);
$next_increment = $row[’Auto_increment’];
echo "Next increment number is " . $row["Auto_increment"];
?>
|