Home Database Mysql Tutorial Access数据库id类型由自动编号改成数字类型后如何再从数字类型改

Access数据库id类型由自动编号改成数字类型后如何再从数字类型改

Jun 07, 2016 pm 03:50 PM
access one how number database type serial number automatic

一套网页,初级小技术员编写的,多次用到了固定id的链接,如:a href=list.asp?id=11站内新闻/a。而客户恰好不慎将这个内容删除了。要修复,关键就是补上这个id,id字段又必须还是“自动编号”(其他内容可以让客户自己重新填上)。下面是过程。 1、给数据库

    一套网页,初级小技术员编写的,多次用到了固定id的链接,如:站内新闻。而客户恰好不慎将这个内容删除了。要修复,关键就是补上这个id,id字段又必须还是“自动编号”(其他内容可以让客户自己重新填上)。下面是过程。

1、给数据库备份(如果你没有先备份的习惯,那就从现在起开始养成这个习惯)

2、打开数据库,发现原数据库表名为test。单击选定,然后点上面的“设计”,将id字段的数据类型改为“数字”,关闭保存。

3、双击test,在id字段添上你需要的值,如11。在这里,也可以修改已有的数据的数值。关闭表。这时,该字段是不能改回“自动编号”数据类型的。

4、右键单击表test-->复制,然后右键点一下空白处,粘贴-->,表名称写入“test1”,选择“只粘贴结构”-->确定。新表test1生成了。

5、单击选中test1,点击上面的“设计”。把id字段的数据类型改为“自动编号”。因为这时test1里是没有数据的,所以可以修改成功。

6、右键单击表test-->复制,然后右键点一下空白处,粘贴-->,表名称写入“test1”(与步骤4相同),但选择“将数据追加到已有的表”-->确定。

7、将表test改名为test_bad,将test1改名为test。结束。这里要养成良好习惯,不要猴急地把原test表删除,而是改名。等全部测试成功后,再删不迟。

8、总结:access的“自动编号”数据类型可以改成数字等其他类型,但有数据后,就不能改回来了。那么就先复制一个结构,在有数据之前把该类型改回“自动编号”,然后再导入数据。这时该字段的值也是导入的,而不是自动生成的,但以后再添加新数据时又是自动生成的了。改变了自动编号的值,所有程序都无需改变。很简单。

最后,别忘了:1、让这个技术员抓紧时间提高自己的编程水平,更不要偷懒;2、告诉客户,此类文章不能删除(或者直接去掉“删除”功能)。

 

详解Access数据库自增长字段值的修改及初始值的设置

Access数据库自增长字段值的修改及初始值的设置是本文我们主要要介绍的内容,Access的自增长字段的值的修改,发现原来Access自增长比起SQL Server的标识列有一定的灵活性。比如Access的自增长字段可以直接insert记录时指定数值,但是不要和已经有的记录的该字段值重复了,会主键冲突的,而SQL Server就不行了。

  并且如果某个自增长序号已经有记录了,那么删除这条记录后还可以设定该值作为新记录的序号值。但是对于已有的记录,就不能修改自增长字段的值了,如果确需修改,有两种方法,要不就是删除原记录,重新插入数据时指定该字段值。要不就是去除自增长属性,修改成一个不重复的值保存后再将该字段类型设置成自动增长。

  那么,如果想设定Access数据库自增长字段的初始值该怎么办呢,这个较为简单,可以通过特定SQL语句即可实现。

  如果创建表结构时想设定自增长字段的初始值可以这条语句:

  CREATE TABLE 表名自增长字段名 AUTOINCREMENT 1000 10), ItemId LONG Quantity LONG

  如果表结构已经存在,可以通过这条语句修改:

  ALTER TABLE 表名 ALTER COLUMN 自增长字段名 COUNTER 2000 50

  如果想复位自增长种子重新开始,可以这样:

  ALTER TABLE 表名 ALTER COLUMN 自增长字段名 COUNTER 1 1

  好了,SQL ServerAccess两种数据库的自增长(标识列)都可以修改字段值了。有什么用呢,呵呵,很有用,对于我目前手同的工作来说,就是可以在程序中增加数据导入导出文本文件了,并且导入后一些关键的排序主键字段值不会发生改变,能保持原有数据的编号。

 

 

Statement of this Website
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

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 ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to convert deepseek pdf How to convert deepseek pdf Feb 19, 2025 pm 05:24 PM

DeepSeek cannot convert files directly to PDF. Depending on the file type, you can use different methods: Common documents (Word, Excel, PowerPoint): Use Microsoft Office, LibreOffice and other software to export as PDF. Image: Save as PDF using image viewer or image processing software. Web pages: Use the browser's "Print into PDF" function or the dedicated web page to PDF tool. Uncommon formats: Find the right converter and convert it to PDF. It is crucial to choose the right tools and develop a plan based on the actual situation.

How to read dbf file in oracle How to read dbf file in oracle May 10, 2024 am 01:27 AM

Oracle can read dbf files through the following steps: create an external table and reference the dbf file; query the external table to retrieve data; import the data into the Oracle table.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How does Go WebSocket integrate with databases? How does Go WebSocket integrate with databases? Jun 05, 2024 pm 03:18 PM

How to integrate GoWebSocket with a database: Set up a database connection: Use the database/sql package to connect to the database. Store WebSocket messages to the database: Use the INSERT statement to insert the message into the database. Retrieve WebSocket messages from the database: Use the SELECT statement to retrieve messages from the database.

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

Interpretation of Botanix: decentralized BTC L2 for network asset management (with interactive tutorial) Interpretation of Botanix: decentralized BTC L2 for network asset management (with interactive tutorial) May 08, 2024 pm 06:40 PM

Yesterday, BotanixLabs announced that it has completed a total of US$11.5 million in financing, with participation from Polychain Capital, Placeholder Capital and others. Financing will be used to build the decentralized EVM equivalent of BTCL2Botanix. Spiderchain combines the ease of use of EVM with the security of Bitcoin. Since the testnet went live in November 2023, there have been more than 200,000 active addresses. Odaily will analyze Botanix’s characteristic mechanism and testnet interaction process in this article. Botanix According to the official definition, Botanix is ​​a decentralized Turing-complete L2EVM built on Bitcoin and consists of two core components: Ethereum Virtual Machine

See all articles