PostgreSQL is not very familiar with it. I don't know if there is any good way to retrieve the number of records in all tables and tables in the data. Please tell us if you have any good methods. Thank you !!
There was a database with more than 200 tables in it, and a simple PHP program implementation was written in a stupid way.
Retrieve all tables
PostgreSQL # \ dt
Then I wrote a PHP program to get the number of table records. Of course, if your table is small, simply use select count (*) from table !!
<? PHP
$ Tables = "members
News
Newscatagory
Products
Productscatagory ";
$ Table_array = explode ("\ n", $ tables );
Foreach ($ table_array as $ v ){
$ V = trim ($ V );
Echo $ v .",";
$ T = table_records ($ V );
Echo $ T. "<br> ";
}
Function table_records ($ v) {// obtain the number of records in the table
Global $ dB;
If ($ v ){
$ RT = $ db-> get_one ("select count (*) as count from $ v ");
Return $ RT ['Count'];
} Else {
Return 0;
}
}
?>