Questions tagged [auto-increment]

a database constraint that automatically increases from the last record when making an INSERT

AUTO_INCREMENT is a flag set on a field in a database table that forces the RDBMS to create a unique identifier for the record. This is useful when no other obvious primary key field is apparent in a record.

Useful questions

Related tags

2677 questions
0
votes
1 answer

I thought auto_increment prevents duplicates entries?

I am getting duplicate entry error for key 'primary' when trying to insert values and I can't get past it. I added auto_increment to the integer part of the composite key (term_taxonomy_id). Isn't auto_increment supposed to resolve duplicate entries…
radhadman
  • 115
  • 8
0
votes
1 answer

Skip every 100th number in Row_Number fucntion in sql

I have to make a auto increment sequence but it need to skip every 100th number and go to next number. Example: 1, 2, 3, ... 99,101,102...199,201,202 Could anyone help on this I tried rownum() over (partition by column_name)+1. But it is updating…
0
votes
1 answer

MySQL auto_increment setting error problem

everyone! Currently, I am making a new schema using MySQL, and trying to alter auto_increment from 100. But sometimes when I set auto_increment from 100, it starts from 101, not 100. Is there anybody who knows why??? When I set auto_increment = 100…
Mihee Kim
  • 1
  • 1
0
votes
0 answers

Auto increment id after group by some values using sequelize

I have table already have id and it's unique. id* status other column ...... amount 1 1 100 2 1 1000 3 1 1234 4 1 3000 5 2 …
0
votes
2 answers

Set AutoIncrement value with Subquery in MySQL

I am trying to provide the value for auto increment value through the subquery in mysql I tried with this command alter table xxx auto_increment = (select max(id) from xxx) ; But am getting the syntax error as You have an error in your SQL syntax;…
0
votes
1 answer

How to increment manually semVer GitTools in azure pipeline?

I use GitTools for auto increment semVer. The current version: v1.1.1 calculate SemVer: "MajorMinorPatch": "1.2.0" when incrementing the patch: git commit -a -m "+semver: patch [skip azurepipelines]" --allow-empty Write-Host…
0
votes
1 answer

MySQL can't show table after altering auto_increment

I created two tables like this and I want to change the added data's id so I use alter table member auto_increment=5; after this, it couldn't show my member table. It shows error 2013: lost connection to MySQL server during query. I thought my…
0
votes
1 answer

mysql change autoincrement to different value

In a table in mysql db (version: 5.7.37) I have an auto-increment field (id column). The table is a huge one, but sometime we delete records (so id of 1 million is not 1 millions records) - still a huge one after the deletion. Sometime the id…
Eitan
  • 1,286
  • 2
  • 16
  • 55
0
votes
1 answer

Composite Primary Key and autoincremented ID

I am trying to build a composite primary key for my tabels. They should also have a self incremented id. My problem is that when I use a composite primary key the ID becomes NULL (as seen in the pictures) here it works as it should but no composite…
0
votes
1 answer

Auto Increment missing in my users table after importing on production. How should I modify it?

When I run this query : ALTER TABLE `users` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=56; It gives me error like : #1833 - Cannot change column 'id': used in a foreign key constraint 'designation_user_user_id_foreign'…
Nage
  • 23
  • 1
  • 5
0
votes
1 answer

Scoped/composite surrogate keys in MySQL

Here's an excerpt of my current database (changed the table-names for an easier understanding): Pet(ownerFK, id, name, age) Owner(id, name) Where id is always a surrogate key, created with auto_increment. I want to have the surrogate key Pet.id to…
Marcel Jackwerth
  • 53,948
  • 9
  • 74
  • 88
0
votes
1 answer

Move generated files whilst incrementally renaming them (in ascending order)

Pictures are generated in a directory, each with the same name. I would like to move them to another directory and rename them in an ascending order using a batch file, e.g. bild1.png -> 1.png, next time bild1.png -> 2.png and so on. Currently the…
0
votes
1 answer

Identity out of order with system versioned table

I'm using system-versioned (temporal) tables with an identity column and noticed that sometimes the start time of a row in the history table has a higher identity value than a row with a later start time. See example…
SBFrancies
  • 3,987
  • 2
  • 14
  • 37
0
votes
1 answer

Java/Hibernate: How can I insert a specific value for a column with autoincrement / @GeneratedValue

I have a table with an id column that autoincrements, and a Java object that has a getter annotated with @GeneratedValue(strategy = GenerationType.AUTO). This works great when saving, however for a unit test I want to specify the ID so that it is…
Aaron Silverman
  • 22,070
  • 21
  • 83
  • 103
0
votes
1 answer

How do I auto-increment subsets?

Consider a MWE with a table with four columns: ORDER_BASIS, GROUP_1, GROUP_2 and ORDER_VALUE. The first three are populated with data and I would like to now populate ORDER_VALUE with an integer (starting with 1 for each subset) that indicates the…
CraigS
  • 37
  • 1
  • 7