Sybase auto-increment field skip handling

Source: Internet
Author: User
Tags sybase sybase database
Reason and impact of the Code SKIP:
In the sybase database, if the database is enabled, the database service process is forcibly terminated due to abnormal reasons (crash or power failure.
The Automatically increasing field will generate a jump. When you insert a record into the data table, the auto-increment field will jump to a very large value, so that the auto-increment value of the primary key is very likely to be exhausted, or because the value is too large, the data type such as int type in the application cannot accommodate such a large value, however, you cannot perform related operations in the program.

Solution:
If no skip occurs, follow these steps:
1. Run the [select 'SP _ chgattribute '+ name +', ''' + 'Identity _ gap '+ ''' +', 60 go'
From sysobjects
Where type = 'U ']. 60 indicates a value based on the perception. Generally, the larger the value, the better the performance. However, the larger the value, the larger the number of hops when the database service process ends abnormally.
2. Copy the result of 1 to the SQL editing area and then execute it.
If a checkpoint has already occurred, export the data in the table, recreate the data table, and then execute 1 and 2. Then import the data.

After that:
The biggest problem with the Sybase auto-incrementing field is that when the database is transplanted, if the data table is associated by the auto-incrementing primary key, after the data is re-imported, maybe the Foreign keys in the Master/Slave table cannot be associated. I didn't expect this at the beginning. Now we have a boat and there is no way to do it. In the future, you should use the auto-increment field as the primary key with caution.

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.