search
HomeDatabaseMysql Tutorial如何让access自动编号从1开始排序实现方法

ACCESS数据库自动编号从1开始-如何让access自动编号重新从1开始排序,很是疑惑,于是搜集整理一些实用方法,希望可以帮助你们

方法一
  删个那个自动编号的字段,再建一个同样的自动编号字段即可。
方法二
  自动编号是一直增加的(每次都加1),你再增加一条记录它的编号会在前面的基础上加1(删除的也算),如果你编号为1的记录被删除了,你想再要从1开始,可以打开Access数据库,选择工具,再选择数据库实用工具,单击压缩和修复数据库,这样就OK了.
方法三:(没试过)
 1、在access里新建一个查询。
 2、把视图改为sql视图。
 3、在里面输入
  ALTER TABLE 表名 ALTER COLUMN [自动编号字段名] COUNTER (你要的初始值, 1)
  例如:
  ALTER TABLE [user] ALTER COLUMN [id] COUNTER (1001, 1)
 4、运行后,编号就从1001开始了。
数据库表中自动编号字段用一段时间后,把数据全删了再新增数据时也不会从1开始的,而是接着以前的值加1或增加设定的步值,Access,mysql,mssql等都是这样的。怎么才能让数据清空后自动编号从1开始?有时候又想让Access数据库自动编号不从1开始,而想从指定的值开始,或让ACCESS自动编号一次增长指定的步值?以下办法供参考:
针对ACCESS数据库
1、想保留数据的
1.1可以把自动编号字段删了,然后再加个自动编号的字段
1.2(1)、在access里新建一个查询。
  (2)、在设计查询界面右键选择SQL视图。
  (3)、输入如下SQL语句,执行
  Alter TABLE 表名
Alter COLUMN [自动编号字段名] COUNTER (初始值,步值)
如:想让TT表自动编号字段id从1开始,可以:Alter TABLE TT Alter COLUMN id COUNTER (1, 1)
想让TT表自动编号字段id从100开始,每次增加10,可以:Alter TABLE TT Alter COLUMN id COUNTER (100, 10)
:1.2方法,可以在刚建数据库、清空数据库或有数据时执行,默认执行DDL语句后,如ID是设为主键的将被取消,如果数据库中有值可以出现ID重复,想执行后仍有主键设置可以改为 Alter COLUMN [自动编号字段名] COUNTER (初始值, 步值) primary key(但指定初始值必不能跟已经存在的ID值相同才行)
2、不想保留数据,只想把自动编号恢复从1开始
2.1、复制原来数据库表,只复制数据结构即可。
2.2、删除所有数据后,选择工具,再选择数据库实用工具,单击压缩和修复数据库.
2.3、删除所有数据后,把自动编号字段改为不自动编号,保存,然后再改成自动编号
MSSQL数据库、MYSQL数据库保留数据时可以参看1.1,不保留数据时可以执行:truncate table 表名,可以快速清空整个表数据使自动编号初始开始
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Reduce the use of MySQL memory in DockerReduce the use of MySQL memory in DockerMar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How to solve the problem of mysql cannot open shared libraryHow to solve the problem of mysql cannot open shared libraryMar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

How do you alter a table in MySQL using the ALTER TABLE statement?How do you alter a table in MySQL using the ALTER TABLE statement?Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin)Run MySQl in Linux (with/without podman container with phpmyadmin)Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overviewWhat is SQLite? Comprehensive overviewMar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

Running multiple MySQL versions on MacOS: A step-by-step guideRunning multiple MySQL versions on MacOS: A step-by-step guideMar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

How do I configure SSL/TLS encryption for MySQL connections?How do I configure SSL/TLS encryption for MySQL connections?Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor