How can I change the Access database id type from the automatic number type to the numeric type?

Source: Internet
Author: User
A set of web pages, written by beginners and frequently used fixed id links, such as ahreflist. asp? News a on the id11 website. The customer accidentally deleted the content. To fix the problem, the key is to add the id, and the id field must be "automatically numbered" (other content can be filled in by the customer ). The following is the process. 1. Database

A set of web pages, written by beginners and frequently used fixed id links, such as a href = list. asp? Id = 11-site News/. The customer accidentally deleted the content. To fix the problem, the key is to add the id, and the id field must be "automatically numbered" (other content can be filled in by the customer ). The following is the process. 1. Database

A set of web pages, written by junior technicians, used fixed id links multiple times, such as intra-site News. The customer accidentally deleted the content. To fix the problem, the key is to add the id, and the id field must be "automatically numbered" (other content can be filled in by the customer ). The following is the process.

1. Back up the database (if you do not have the habit of backing up the database first, you should start to develop this habit from now on)

2. Open the database and find the original database table named test. Click Select, and click "design" to change the data type of the id field to "number.

3. Double-click test to add the value you need in the id field, for example, 11. Here, you can also modify the values of existing data. Close the table. In this case, the field cannot be changed back to the "auto-numbered" data type.

4. Right-click the table test --> copy, right-click the blank area, paste -->, write the table name to "test1", and select "paste only structure" --> OK. The new table test1 is generated.

5. Click test1 and click design above ". Change the Data Type of the id field to "automatic number ". Because there is no data in test1, the modification can be successful.

6. Right-click the table test --> copy, right-click the blank area, and paste -->. The table name is written to "test1" (same as step 4 ), but select "append data to an existing table" --> OK.

7. Change test to test_bad and test1 to test. End. Here we need to develop a good habit. Instead of deleting the original test table urgently, we should change our name. After all tests are successful, it is not too late to delete them.

8. Conclusion: The "auto-numbered" data type of access can be changed to other types, such as numbers. However, once there is data, it cannot be changed back. Copy a structure, change the data type back to "automatic number", and then import the data. At this time, the value of this field is also imported, rather than automatically generated, but it is automatically generated when new data is added later. The value of the automatic number is changed, and no change is required for all programs. Very simple.

Finally, don't forget: 1. Let the technician hurry up to improve their programming skills, let alone be lazy; 2. Tell the customer that such articles cannot be deleted (or directly remove the "delete" function ).

Detailed description of modifying the self-increment field value of the Access database and setting the Initial Value

The modification of the Self-increment field value of the Access Database and the setting of the initial value are what we will introduce in this article. The modification of the value of the Self-increment field of Access is as follows, it is found that the self-growth of Access is more flexible than the identity column of SQL Server. For example, the auto-increment field of Access can be specified when the record is directly inserted, but it should not be repeated with the field value of the existing record. It will conflict with the primary key, and SQL Server will not work.

If a self-increasing sequence number already exists, you can delete this record and set this value as the sequence number of the new record. However, for existing records, the value of the Self-increment field cannot be modified. If you need to modify the value, you can delete the original record or specify the value of this field when inserting data again. Otherwise, you can delete the auto-increment attribute, modify it to a non-repeating value, and then set the field type to auto-increment.

What should I do if I want to set the initial value of the Self-increment field of the Access database? This is relatively simple and can be achieved through a specific SQL statement.

If you want to set the initial value of the auto-increment field when creating the table structure, you can use this statement:

Create table Name (auto-increment field name AUTOINCREMENT (1000, 10), ItemId LONG, Quantity LONG)

If the table structure already exists, you can use this statement to modify it:

Alter table name alter column auto-increment field name COUNTER (2000, 50)

If you want to reset the auto-growth seed and start again, you can do this:

Alter table name alter column auto-increment field name COUNTER (1, 1)

All right, the field values can be modified for the auto-increment (ID column) of SQL Server and Access databases. What's the use? Oh, it's very useful. For my current work, I can add data to the program to import and export text files, in addition, the values of some key sort primary key fields after the import will not change, and the numbers of the original data will be retained.

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.