RE: [Info-ingres] Re: is there an equivavlent to auto_increment i n ingres ?
- From: Paul White <pwhite@xxxxxxxxxxxxxxxxx>
- Date: Wed, 20 Jul 2005 11:04:03 +1000
The advantage of using the unique system maintained key is so you can
differentiate between otherwise duplicate records. Very useful if you have
thousands of rows being inserted and you dont want to go off to a secondary
table to increment a unique number for every row.
I've seen some pretty ugly (is that grammatically correct?) attempts to deal
with this problem.
-- Timestamp, put a sleep(1)in between each insert. You also need user_id,
some unique session id in the key.
-- tid (aaaaaarrrrgggghhhhhh!!!)
-- Read all the records into an array, assign a number, delete the records,
re-insert one by one.
-- pseudo random generator controlled by the client.
By the way, here is an example:
create table users (
userid table_key with system_maintained,
username varchar(100) ) ;
insert into blah (username) values ('fred');
insert into blah (username) values ('mary');
insert into blah (username) values ('paul');
select * from blah;
userid username
\001\000\000\000\000\000\000\000 fred
\002\000\000\000\000\000\000\000 mary
\003\000\000\000\000\000\000\000 paul
help blah;
Name: blah
Owner: ingres
Created: 29/03/05 14:12:49
Type: user table
Version: II2.6
Column Information:
Key
Column Name Type Length Nulls Defaults Seq
userid TblKey,SM no value
username varchar 100 yes null
table_key Ingres maintains a unique identifier for the table.
object_key Ingres maintains the unique identifier for the database.
The manual needs a bit of work in this area - I have an issue open on this.
Check out sqlref.pdf. search for "table_key" and "system maintained". Also
look at some of the correspondence on the the newsgroup
comp.databases.ingres.
There are limitations to copying data to / from these tables (as in other
dbms) and you shouldnt reference the fields in other tables.
Paul
.
- Follow-Ups:
- Prev by Date: Re: [Info-ingres] Re: is there an equivavlent to auto_increment in ingres ?
- Next by Date: Re: [Info-ingres] Re: is there an equivavlent to auto_increment in ingres ?
- Previous by thread: is there an equivavlent to auto_increment in ingres ?
- Next by thread: Re: [Info-ingres] Re: is there an equivavlent to auto_increment in ingres ?
- Index(es):
Relevant Pages
|