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
1
vote
0 answers

duplicate primary key error after altering auto_increment value

I have a mysql innoDB table with over 6000 records. The primary key (ID) is set to be auto_incremented. At this time the auto_increment value was 41804. I inserted over 2000 records through insert statements, and found some of the queries to have…
dagger
  • 515
  • 2
  • 6
  • 17
1
vote
1 answer

controlling auto incremented column?

i have a table called ptb_users like this: id (auto increment) | name | email 1 john john@email.com 2 kate kate@gmail.com 29 harry harry@email.com 10016 …
James Cart
  • 11
  • 2
1
vote
1 answer

Hibernate provides next generated id 32768 and so on 65536, 98304

EMPLOYEE.java @Entity @Table(name="EMPLOYEE") public class Employee implements Serializable { @Id @GeneratedValue( strategy = GenerationType.TABLE) EMPLOYEE (TABLE) 1 3/13/2013 911 Jack Bauer 32768 3/13/2013 911 Jack Bauer 65536 …
Shahid Ghafoor
  • 2,991
  • 17
  • 68
  • 123
1
vote
3 answers

How do I insert the auto-increment ID into a MySQL table using MySQL ODBC with ASP.Net/C#?

I am using MySQL ODBC to insert data into a MySQL table. The first column in the table is an ID that is of type int and auto increments. When I insert the data for the very first row, what should the value be for @ReqID, as shown below? Also, how do…
Monica
  • 1,585
  • 3
  • 23
  • 34
1
vote
1 answer

create a PK column combining letters and numbers

I have a product purchasing system and I want to have a unique identifier with the format PID*n*, where n is an autoincrementing number. PID00001 PID00002 PID00003 How can this be done with VB6 and MySQL?
Handy Manny
  • 388
  • 1
  • 4
  • 20
1
vote
0 answers

What's the expected behavior for MySQL load data infile for auto increment field?

I have a production MySQL database, for some reason, I need to load some data into it from our development database which has similar schema. The data is output through mysql -e "select * from :>somefile method. The schema for the target table has…
Wei
  • 718
  • 1
  • 6
  • 18
1
vote
1 answer

Creating a user-defined function in MySQL to handle auto_increment

I am trying to create a user-defined function in MySQL in order to generate unique numbers. As the auto_increment feature of MySQL just increments its seed by one, I need to have such a function to handle fields that need to be incremented by more…
samanca
  • 153
  • 3
  • 11
1
vote
2 answers

LOAD DATA LOCAL INFILe: loading data form text file auto incerment syntax

I'm trying to load data from a .txt file into mysql. The table looks like this: +-------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra …
DBWeinstein
  • 8,605
  • 31
  • 73
  • 118
1
vote
1 answer

need help assigning user inputs into an increasing string array

Basically what I am overall trying to do is: One of your professors hears of your emerging programming expertise and asks you to write a SINGLE program that can be used to help them with their grading. The professor gives three 50-point exams and a…
Joseph Mindrup
  • 65
  • 1
  • 3
  • 10
1
vote
0 answers

MySQL's auto_increment not incrementing by 1

I want auto_increment to increment by 1 each time I insert a row. It doesn't matter if I later delete a row in the middle, I always want it to increment by 1. The problem is that MySQL keeps incrementing by 10. It goes from 1 to 11, to etc. I've…
user1831680
  • 73
  • 1
  • 8
1
vote
1 answer

how to apply autoincrementation in rails 3.2

I was doing a shopping list project in ruby on rails. While creating the table named products, by mistake I have removed the autoincrement option from id field of my table products. Can any one tell me ,how can I reinsert the option of autoincrement…
1
vote
2 answers

Update Query with LEFT JOIN , Variable and Autoincrement Using MySQL

I am stuck on a situation. Here is the table structures. default_category category_id | parent_id | name | symbol ----------------------------------------------------------- 1 | 1 | SMT Equipment | SMT …
Muhammad Raheel
  • 19,823
  • 7
  • 67
  • 103
1
vote
2 answers

SQLite doesn't save a primary key

The following code doesn't save a "eventid" in the sqlite db by default. I can see all the rows with echo but the event ID is emply... Any ideas why? Thanks a lot. $now = time(); try{ if (!file_exists("testgb")){ $db = new…
1
vote
2 answers

Android SQLite ID

I'm wondering how does SQLite deal with adding new rows after deleting some rows before it. For example I have 3 records/rows and their 3 auto increment ID's : ID 1 ID 2 ID 3 I delete the record with ID 2, so now I have : ID 1 ID 3 Now I add a…
user1880779
  • 2,038
  • 8
  • 30
  • 40
1
vote
2 answers

How to link foreign key to auto-incremented primary key in Oracle?

I have two tables whose common field is Load_ID. The PK of the first has a one-to-many relationship with the FK of the second. For example: Table1: 1, someValue Table2: 1, value1, ... 1, value2, ... 1, value3, ... I've embedded the actual…
user1985189
  • 669
  • 5
  • 16
  • 25