autoincrement

What size INT should I use for my autoincrement ids MySQL

Currently we're using INT(21)* for all autoincrement id columns in out 30+ table database. We are a blogging site, and have tables storing members, comments, blog posts and the like. I'm quite sure we will never reach the limit of our INT(21) id columns, and would like to know: If using INT(21) when I am sure we'll never need it is ...

Subsonic Oracle autoincrement problem

Hello guys; I think this question has been done before, but I don't find a clear answer. I have migrated SQl Server 2005 database to oracle 11. I am using subsonic 2.1. I have manged to create all the data layer classes, and generates everything well. But the problem turns up when I try to make an insert in the database: Oracle does not...

How can I have two columns in SQL Server auto increment?

I have two columns in a table of a SQL server DB that I would like to autoincrement when new fields are added. However, Managment Studio wont allow me to set two columns to IDENTITY. Is there some other way to do this? ...

How to create auto increment primary key?

I am using Google AppEngine (Java) and would like to have the primary key to be auto incrementing, preferably increasing by 1. IdGeneratorStrategy.INCREMENT seems to be not supported in AppEngine. Is IdGeneratorStrategy.SEQUENCE what I need? ...

Is using rand() in an INSERT statement also slow?

The MYSQL rand() function is notoriously slow in select statements, is this true for insert statements as well? I would like to insert a new row with random number in the following way: insert into new_table (field1, field2, randomField) values ('Hello', 'Ola', rand()); Will the rand() function become slow as the table gets larger a...

(Solved) How to return autoincrement value in insert query in SQLite?

In my project I use System.Data.SQLite. Database has table Tags, which contains autoincrement primary field ID (type Integer). When I write: using (SQLiteCommand command = conn.CreateCommand()) { command.CommandText = "insert into Tags(name) values(@name) returning into @id"; command.Parameters.Add("@id", DbType.Int32).Direction =...

void * arithmetic

#include<stdio.h> int main(int argc,char *argv[]) { int i=10; void *k; k=&i; k++; printf("%p\n%p\n",&i,k); return 0; } Is ++ is legal operation on void* ? Some books say that it's not but K & R doesn't say anything regarding void * arithmetic ( pg. 93,103,120,199 of K &R 2/e) Please clarify. PS : GCC doesn't comp...

mysql auto increment primary key id's

How do you look for a delete ID number that has been used, but deleted as is no longer used, before you just append on top of the last ID number that has been added For example: ID Name 1 Orange 5 Apple I have auto increment on, I want to add Banana in to number 2, but auto increment is adding it as ID 6 I'm ...

How to change id in existing MySQL tables with data to autoincrement from last highest id?

I have just managed to migrate a pretty big database from SQL Server to MySQL. I didn't set the primary keys to auto increment during the migration because the tables have relationships based on ids as primary keys which are foreign keys in another table. Now for adding new records I want to alter the primary key 'id' columns in all tab...

Autoincrement problem mysql

I've looked for this but no luck so far. I have two tables in mysql, they are configured as parent-child. The parent table has a field of type auto_increment, and the child has a field that references the autoincrement column in the parent. When I do inserts into the parent table everything goes fine. But when I do insert on the child ta...