Hi everybody,
Do I have to create for every table in the databsase a sequence in order to have values for the primary fields or there is some other way to that?
Printable View
Hi everybody,
Do I have to create for every table in the databsase a sequence in order to have values for the primary fields or there is some other way to that?
Yes, this is the common way.
Of course, you can create a script to do it for you.
Can you show me how?
Hi,
CREATE SEQUENCE MY_SEQ START WITH 100
INCREMENT BY 1
NOMAXVALUE
NOCYCLE
CACHE 20;
Its upto you to give the values,,or else it will take the default values.
HTH
SS
Create your sequence
Then use the sequence in your insert statementsCode:CREATE SEQUENCE atable_s
START WITH 1
INCREMENT BY 1
NOMAXVALUE;
HTHCode:INSERT INTO atable.col
VALUES (atable_s.nextval);
It is possible to use one sequence for all tables, if you can live with gaps in primary keys. There's no requirement for table to have its own sequence.Quote:
Originally posted by edli
Do I have to create for every table in the databsase a sequence in order to have values for the primary fields or there is some other way to that?
No, If the database is designed properly all tables should have primary key column/s. Why to create dummy primary key values ?Quote:
Originally posted by TomazZ
Yes, this is the common way.
Of course, you can create a script to do it for you.
hey I think u answered your own questionQuote:
If the database is designed properly all tables should have primary key column/s. Why to create dummy primary key values ?
Quote:
Originally posted by onlysimon
hey I think u answered your own question
:confused: :confused: :confused:
Just to show that for every rule there is an exception, let me mention that in a data warehouse or DW fact table there is generally no requirement to define a PK, synthetic or otherwise, if the table os not the parent of another.