From: Brian Candler Date: 2010-09-05T00:51:02+09:00 Subject: Re: ActiveRecord and incrementing the key Abder-Rahman Ali wrote: > How does the database server manage the incrementing of the key? What is > meant here by the database server is what manages the incrementing of > the key? Mysql: primary key is declared as an AUTO_INCREMENT column. http://dev.mysql.com/doc/refman/5.1/en/example-auto-increment.html Sqlite: if there is an INTEGER PRIMARY KEY then it's the automatically-assigned ROWID. http://www.sqlite.org/autoinc.html Oracle: uses a sequence, something like INSERT INTO foo(id,bar) VALUES(foo_seq.nextval,?) And so on - each of the database adapters has their own logic. See for example activerecord/lib/active_record/connection_adapters/mysql_adapter.rb NATIVE_DATABASE_TYPES = { :primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY".freeze, -- Posted via http://www.ruby-forum.com/.