简体   繁体   English

如何配置mysql数据库的结构

[英]How to configure the structure of a mysql database

Is it possible to restore the previous state of a mysql database through phpmyadmin? 是否可以通过phpmyadmin恢复mysql数据库的先前状态? I have one column in 4 of the tables that have the auto increment. 我在具有自动递增功能的表中有4列。 And my problem is how to begin again in the count of number 1 when I try to add a data. 我的问题是,当我尝试添加数据时,如何从数字1开始重新开始。 I tried deleting all the records then add a record but it doesn't start with 1. How do I do this without building the database over again by typing and selecting the data types. 我尝试删除所有记录,然后添加一条记录,但它不是从1开始的。如何在不通过键入和选择数据类型来重新构建数据库的情况下执行此操作。 What I want to do is to start the counting from 1 again. 我想要做的是再次从1开始计数。 Is it possible? 可能吗?

Open phpMyAdmin and then select the DB you wish to change from the top left panel. 打开phpMyAdmin,然后从左上方面板中选择要更改的数据库。 Now click the "query" button also top left to open a query window where you can then run the sql code below to reset the auto increment count for your table. 现在,单击左上方的“查询”按钮以打开查询窗口,然后您可以在其中运行下面的sql代码以重置表的自动增量计数。

ALTER TABLE your_table_name AUTO_INCREMENT=1

Have you tried ... 你有没有尝试过 ...
ALTER TABLE t2 AUTO_INCREMENT = 1; ALTER TABLE t2 AUTO_INCREMENT = 1;
It will reset the value to the smallest value allowed. 它将值重置为允许的最小值。 Other than that you are out of luck. 除此之外,您还不走运。

If you dont care about the data in the table you can just hit the empty button (make sure you are on the right table). 如果您不关心表中的数据,则可以单击空白按钮(确保您在正确的表上)。 That will tuncate your table and anything you add after that will start at 1. If you set a field to auto increment then each item after that will increase by 1. 这将优化您的表,此后添加的任何内容将从1开始。如果将字段设置为自动递增,则此后的每个项目都会增加1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM