Initializes the self-increment fields for all tables in the database.

Source: Internet
Author: User

The database stored procedures are not very skilled, 1:30 will not write out the function, so I simply wrote a program in PHP. More than 10 databases, each library has hundreds of tables, the data are all emptied, but the table's self-increment field value is still retained the original table, to all one-time restore to the original value, if a table a table modification, do not know to change to se years. In the System library query the table name of the database that needs to be modified $sysdbname= "Information_schema"; $dbarray =array ("DB1", "DB2", "DB3", "DB4", "DB5", "DB6", "DB7", " DB8 "," DB9 "," DB10 "), foreach ($dbarray as $v) {//database to be manipulated $dbname= $v; mysql_select_db (" $dbname ") or Die (" Open db FAILED. "); $query = "Select table_name from ' TABLES ' where table_schema= ' {$sysDbName} ' and auto_increment>1 '; $result =mysql_ Query ($query); $totalRows =mysql_num_rows ($result); echo "Shared". $totalRows. "The table needs to initialize the:


Self-increment fields for all tables in the database are initialized

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.