Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: autoID
Hello,
SQL> drop table my_table;
Table dropped.
SQL> create table my_table(id number, name varchar2(10));
Table created.
SQL> create sequence my_table_seq start with 1 2 increment by 1;
Sequence created.
SQL> create or replace trigger my_table_id
2 before insert on my_table
3 for each row
4 begin
5 select my_table_seq.nextval
6 into :new.id 7 from dual;
Trigger created.
SQL> insert into my_table values(null,'....');
1 row created.
SQL> insert into my_table values(null,'....?');
1 row created.
SQL> select * from my_table;
ID NAME
--------- ----------
1 .... 2 ....?
HTH, Erika
realtime wrote:
>
> I was was wondering if I can create a field that will automatically generate
> a ID number when data is inserted into the rest of the table is this
> possible
Received on Wed Feb 23 2000 - 09:54:01 CST
![]() |
![]() |