auto-increment

How to get last inserted row ID from wordpress database?

My wordpress plugin has a table with a AUTO_INCREMENT primary key field called ID. When a new row is inserted into the table, I'd like to get the ID value of the insertion. The feature is to using AJAX to post data to server to insert into DB. The new row ID is returned in the AJAX response to update client status. It is possible that ...

Set AUTO_INCREMENT starting value in a InnoDB table to zero?

Is there any to get the an AUTO_INCREMENT field of a InnoDB to start counting from 0 not 1 CREATE TABLE `df_mainevent` ( `idDf_MainEvent` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`idDf_MainEvent`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ...

How to turn off auto_increment in Rails Active Record

Is it possible to create primary key without auto_increment flag in ActiveRecord? I can't do create table :blah, :id => false because I want to have primary key index on the column. I looked up documentation but didn't find anything useful. Is it possible to create primary key without auto_increment? ...

Increase increment size to match GUID advantage

Hi, I've been thinking of implementing this system, but can't help but feel there's a catch somewhere. One of the points of using GUID over incrementing int is that, in the future, if you were to merge databases together, you wouldn't have any clashes over the primary key/identifier. However, my approach is to set the increment size t...

Mysql auto increment primary key id's

I have some mysql tables that have auto incrementing id's that are primary keys, but I notice that I never actually use them... I used to think that every table must have a primary key so I guess that is why I created them before. Should I remove them all if I don't use them at all? ...

mysql cluster auto increment out of sync

Hi All, I have two mysql cluster data nodes as Master and slave. But after certain number of rows there is difference between two auto_increment values from one node to another. The difference is of Node 2 is ahead than node 1 by 11. can anyone suggest any fix on this? how to resolve this. and when such type of situation comes? Than...

Auto increment Id's in .net

We need to store xml file in file system. The xml files should have a uniqueId ranging from (00000001 to 99999999) Is there a way to auto increment the ids for any new xml generated. The xml are stored in folder structure which is complex. I tried taking the count of xml files that this seems to be a slow operation. The application is de...

PHP short unique ID generation using auto_increment?

I would like to generate a short, unique ID without having to check for collisions. I currently do something like this, but the ID I currently generate is random and checking for collisions in a loop is annoying and will get expensive if the number of records grows significantly. Normally worrying about collisions isn't an issue, but t...

How can I handle the problem whe AUTO_INCREMENT hit its limit?

Is there any good practice for this? I wish I could solve the problem when primary key hit the limit and not to avoid it. Because this is what will happen in my specific problem. If it's unavoidable... What can i do? This is mysql question, is there Sybase sql anywhere same problem? ...

How to Insert an incremental variable with Javascript/Jquery?

This, I'm sure is a pretty basic question about JavaScript, so apologies in advance. I have simple unordered list: <ul> <li><a href="">Item number 1</a></li> <li><a href="">Item number 2</a></li> <li><a href="">Item number 3</a></li> <li><a href="">Item number 4</a></li> <li><a href="">Item number 5</a></li> </ul> How...

[jQuery] Next and Previous Slide Button Functionality i++, i--

Hi Ya'll, I had a great experience asking a question last time and thought I'd come back for more help. You guys are wonderful. Thank you in advance. I am working with a featured post slider that advances through 4 posts automatically. I would like to add next and previous buttons. I know that I need to attach some kind of .click()...

How to define an auto-increment number for LDAP structure?

Hi all, I have one attribute (groupIDNumber), I want to make it work as auto-increment number? How can we define that attr? Thank for your help, -nm ...

Python MySQL: clean multiple foreign keys table

Hi Everybody, I am working with Python MySQL, and need to clean a table in my database that has 13328 rows. I can not make a simple drop table, because this table is child and also father of other child foreign-keys linked on it. If I try drop table, the system forbidden me. The table is defined with ON UPDATE CASCADE, ON DELETE CASCAD...

Arrays: Counting, Comparing and Increase

Woohoo, I've come to arrays now, thank god. Now, I've got 2 arrays! int colorvalues[][] = {{34,255,255,56},{127,204,11,34},{123,98,127,34},{34,34,127,17}}; Imagine it as a 4x4 pixel picture Now, I want to create a histogram, the distribution of colorvalues from 0 to 255. For example here I've 2*255, 2*127, 5*34 and so on. So I've ...

SQL: Auto Increment question

I have a table with an auto_increment field and sometimes rows get deleted so auto_increment leaves gaps. Is there any way to avoid this or at the very least write an sql query that a) alters the auto_increment value to be the max(current value) + 1 and b) return the new auto_increment value? I know how to write part a and b but can I ...

Oracle database table insertion

I have two tables: create table Number( num number(5)); create table Entry(id number(3), name varchar(50)); How can I increment the num field of Number table in Oracle whenever I insert something in the Entry table? ...

auto_increment value change affect performance in MySQL?

Hello I have changed auto_increment value to 1000000 of a MyISAM table. Does this affect read/write performance? I thought that db engine may look for IDs before ID 1000000 everytime a list of rows is requested. ...

Auto-increment on Azure Table Storage

I am currently developing an application for Azure Table Storage. In that application I have table which will have relatively few inserts (a couple of thousand/day) and the primary key of these entities will be used in another table, which will have billions of rows. Therefore I am looking for a way to use an auto-incremented integer, ...

Can I constraint an AutoIncremented column not to accept values from outside?

I have an AutoIncremented column (ID), and I want to have a constraint that only the database ever fills in this column. Is there a constraint for that? ...

Access front-end, SQL Server back-end skipping autonumber IDs

Question title is the crux of the problem. I have an Access 2007 (2003 format) front-end with a SQL Server 2008 Express back-end. The input form has a subform linked to another table. When adding a record in the main form, the PK field of the table (set to auto increment) is skipping about four IDs (I say about because sometimes it's thr...