hii i have a table which consists of 2 lakh records and numbering is not there for these records.now i want to implement numbering for those records and also to the records which are going to be inserted in future..will it be possible with sequence.if so how???
Total Answers and Comments: 7
Last Update: September 04, 2007 Asked by: srikanth
RE: hiii have a table which consists of 2 lakh r...
hi,01. alter table by adding one more column to the table as serial no.SQL > alter table (serial_no number);02.create a sequence SQL > create sequence test_seqstart with 1increment by 1nominvaluenomaxvaluenocachenocycle;then initialize the sequence SQL > select test_seq.nextval from dual;03. write a small cursor which will update the table something like this-- clip --set serveroutput ondeclare cursor numbering is select rowid from test; rowtrack rowid; beginopen numbering;loop fetch numbering into rowtrack; dbms_output.put_line(rowtrack); exit when numbering%notfound; update test set serial_no=test_seq.nextval where rowid=rowtrack; (test_seq is a sequence)end loop;end;/ -- clip --then run this script as sqlplus / @ test.sqlthis will update all the row in the column serial_no.04.Then next trasaction onward use seqence .
RE: hiii have a table which consists of 2 lakh r...
it is possible by using sequence..
create a such sequence that it's should be started from 1 or any number you want .then increment by our requirments.and set max value 2 lakh.and then by using sequence.NEXTVAL you can generate the numbe automatically...
RE: hiii have a table which consists of 2 lakh r...
SQL> ALTER TABLE EMP ADD SR_NO INT IDENTITY(1,1) 2 ; ALTER TABLE EMP ADD SR_NO INT IDENTITY(1,1) * ERROR at line 1: ORA-01735: invalid ALTER TABLE option
The above commands is not working. Pls specity what do you mean by identity(1,1)