Wednesday, June 12, 2013

0 DB2 SQL: identity column

CREATE TABLE t4(c1 int generated always as identity,c_desc char(20));
-- Below insert would fail
Insert into t4 values ( 1,'A');

image

Because the c1 is defined  generated always as identity, therefore we can not specify the value in the insert statement. Below insert would work.

insert into t4(c_desc) values( 'B')

 

 

CREATE TABLE t5(c1 int generated by default as identity,c_desc char(20));
Insert into t5 values ( 1,'A');
select * from t5;

image

0 comments:

Post a Comment

 

SQL Panda Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates