473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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
Nov 12 '05 #1
2 11524
Ian
db********@yahoo.com wrote:
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


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! =-----
Nov 12 '05 #2
i am not using load utility, i am using sql command like insert in the
jdbc application.

Ian <ia*****@mobileaudio.com> wrote in message news:<41**********@corp.newsgroups.com>...
db********@yahoo.com wrote:
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


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! =-----

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Keith Bannister | last post by:
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace...
10
by: Bernd Hohmann | last post by:
I have a table defined as follows: CREATE TABLE "LOGINS" ( -- UID "PK_NUMBER" INT GENERATED ALWAYS AS IDENTITY (START WITH 1), -- Login Date "DATE" DATE NOT NULL, ... After doing some...
4
by: rs | last post by:
Hi guys Thank you in advance for the help. I developed a simple application using vs.net 2003. running framework 1.1 sp1. the application runs fine on the development machine (win xp). I tried...
4
by: moleskyca1 | last post by:
Hi, In a recent discussion, some of us were in disagreement about the functions the C++ compiler generates. How many functions are generated by the compiler when you declare: class Foo { };...
5
by: alingsjtu | last post by:
Hello, every body. When execute dynamic generated multiple OPENQUERY statements (which linkes to DB2) in SQLServer, I always got SQL1040N The maximum number of applications is already connected...
5
by: Veeru71 | last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS IDENTITY), is there any way to get the last generated value by DB2 for the identity column? I can't use identity_val_local() as...
6
by: JohnQ | last post by:
I like, non-copyable, non-assignable and, most often, non-default-constructable also, as a starting point for class design: class SomeClass { SomeClass(); // disallow default construction...
43
by: JohnQ | last post by:
Are a default constructor, destructor, copy constructor and assignment operator generated by the compiler for a struct if they are not explicitely defined? I think the answer is yes, because...
1
by: Frank Swarbrick | last post by:
We're trying to take advantage of the new ROW CHANGE TIMESTAMP option. Here is a simple table: CREATE TABLE "ACCTASGN"."NUMBER_STATUS" ( "STATUS_CODE" CHAR(1) NOT NULL , "STATUS_DESCRIPTION"...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.