473,618 Members | 3,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11549
Ian
db********@yaho o.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 IDENTITYOVERRID E 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*****@mobile audio.com> wrote in message news:<41******* ***@corp.newsgr oups.com>...
db********@yaho o.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 IDENTITYOVERRID E 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
7280
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 properties.xsd this creates properties.cs
10
14125
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 inserts with JDBC I have this sequence for PK_NUMBER:
4
10763
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 to deploy it on a win 2000 sp4 framework 1.1 sp1. I got the following error Reminder.exe - Common Language Runtime Debugging Services application has generated an exception that could not be handled
4
9483
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
12251
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 to the database. SQLSTATE=57030. Background: I created a linked server to DB2 8.1 database which called GRR_DB2Server. In my stored procedure p_FetchRawData, I need to read some data from this linked server GRR_DB2Server and insert them into
5
32012
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 the INSERTS are happening in a different session. Eg, We have the following table....
6
1963
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 SomeClass(const SomeClass&); // disallow copy construction SomeClass& operator=(const SomeClass&); // disallow assignment public:
43
3798
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 "there is no difference between a struct and a class except the public/private access specification" (and a few minor other things). When I create a class, I always start by declaring the default constructor, copy constructor and assignment operator...
1
11884
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" VARCHAR(40) NOT NULL , "LAST_UPDATE" TIMESTAMP NOT NULL GENERATED ALWAYS FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP
0
8150
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8593
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8303
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7124
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6098
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.