ID列不会随INSERT INTO递增。
我与:
production:
adapter: jdbc
driver: com.ibm.db2.jcc.DB2Driver
url: jdbc:db2://142.123.123.123:123/D2TZMSTR
connection_alive_sql: "SELECT 1 FROM SYSIBM.SYSDUMMY1 FETCH FIRST 1 ROWS ONLY"
host: 142.123.123.123
port: 123
database: ESTIPROD
tablespace: ESTIMATE
username: monkey
password: business
encoding: unicode
Blockquote
class CreateBids < ActiveRecord::Migration
def self.up
create_table :practices, :primary_key => "practice_id", :force => true do |t|
t.string :practice_no, :null => false, :limit => 3
t.string :practice_name, :null => false, :limit => 50
t.timestamps
end
# Create alternate index for practice_no
add_index :practices, :practice_no
# Populate Practice table with practices who including into BID project
Practice.create(:practice_no => '001',
:practice_name => 'Mainframe'
)
Practice.create(:practice_no => '002',
:practice_name => 'Unix'
)
...
end
当我执行&#39; rake db:migrate&#39;时,我收到了来自我的大型机的以下消息命令:
ActiveRecord :: JDBCError:com.ibm.db2.jcc.am.SqlIntegrityConstraintViolationException: DB2 SQL错误:SQLCODE = -803,SQLSTATE = 23505,SQLERRMC = PRAC19S5; 0000000201,&gt; DRIVER = 4.15.99: INSERT INTO实践(created_at, practice_id, practice_name, practice_no, 的updated_at) 价值观(&#39; 2014-03-26 19:27:31.749000&#39;, 的 0 下, &#39; Unix的&#39 ;, &#39; 002&#39 ;, &#39; 2014-03-26 19:27:31.749000&#39;)
来自IBM:
-803 插入或更新的值是无效的,因为索引空间中的索引索引空间名称&gt;表格的约束列,因此没有两行可以包含那些&gt;列中的重复值。 RID OF EXISTING ROW是X记录ID
我们都明白,价值应该是:
VALUES ('2014-03-26 19:27:31.749000',
1,
'Unix',
'002',
'2014-03-26 19:27:31.749000')
| PRACTICE_ID | PRACTICE_NO | PRACTICE_NAME | CREATED_AT | UPDATED_AT |
1_| 0 | 001 | Mainframe | 2014-03-26-19.27.29.279000 | 2014-03-26-19.27.29.279000 |
有什么想法吗?