Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 09:01 AM
db2group88@yahoo.com
Guest
 
Posts: n/a
Default generated by default or as always

i would like to know when i create a table with identity column,
should i used generated by default or generated as always. since when
i create this table, i might copy some data from another table with
identity column also, (so if i use generated as always, i can't do
insert into new_tables select * from old_table), then i might also
insert new data into this new table (if i do generated by default,
then the new table could have the same identity column value as the
data i copy from another table. please advice
  #2  
Old November 12th, 2005, 09:01 AM
Ian
Guest
 
Posts: n/a
Default Re: generated by default or as always

db2group88@yahoo.com wrote:
[color=blue]
> i would like to know when i create a table with identity column,
> should i used generated by default or generated as always. since when
> i create this table, i might copy some data from another table with
> identity column also, (so if i use generated as always, i can't do
> insert into new_tables select * from old_table), then i might also
> insert new data into this new table (if i do generated by default,
> then the new table could have the same identity column value as the
> data i copy from another table. please advice[/color]

The reason people use 'generated always' is so that the database will
prevent users (or applications) from inserting their own values into
the identity column, no matter what. When a user can assign a value
to an identity column you run the risk of causing problems when the
identity runs into a duplicate value.

It is possible to LOAD data into a generated-always column using LOAD
with the MODIFIED BY IDENTITYOVERRIDE option. If you do this, though,
make sure you set the appropriate starting point for your identity to
avoid conflicting values.


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
  #3  
Old November 12th, 2005, 09:01 AM
db2group88@yahoo.com
Guest
 
Posts: n/a
Default Re: generated by default or as always

i am not using load utility, i am using sql command like insert in the
jdbc application.

Ian <ianbjor@mobileaudio.com> wrote in message news:<41052af4$1_1@corp.newsgroups.com>...[color=blue]
> db2group88@yahoo.com wrote:
>[color=green]
> > i would like to know when i create a table with identity column,
> > should i used generated by default or generated as always. since when
> > i create this table, i might copy some data from another table with
> > identity column also, (so if i use generated as always, i can't do
> > insert into new_tables select * from old_table), then i might also
> > insert new data into this new table (if i do generated by default,
> > then the new table could have the same identity column value as the
> > data i copy from another table. please advice[/color]
>
> The reason people use 'generated always' is so that the database will
> prevent users (or applications) from inserting their own values into
> the identity column, no matter what. When a user can assign a value
> to an identity column you run the risk of causing problems when the
> identity runs into a duplicate value.
>
> It is possible to LOAD data into a generated-always column using LOAD
> with the MODIFIED BY IDENTITYOVERRIDE option. If you do this, though,
> make sure you set the appropriate starting point for your identity to
> avoid conflicting values.
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 100,000 Newsgroups - 19 Different Servers! =-----[/color]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.