GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  Oracle
Go To First  |  Previous Question  |  Next Question 
 Oracle  |  Question 20 of 244    Print  
how to apply the generated sequence on the tables?

  
Total Answers and Comments: 3 Last Update: March 17, 2009     Asked by: smitesh shinde 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Dinesh
 

Hi, If u r having sequence name is dept_seq

create seqeunce dept_seq

start with 10

increment by 10

no chache

no cycle

Then u can use this sequence like this

insert into dept(deptno, dname, loc)  values(dept_seq.nextval, <any dname>, <any location name>

try this one..

Regards

Dinesh



Above answer was rated as good by the following members:
mittu.jangid
April 10, 2006 02:47:07   #1  
Dinesh        

RE: how to apply the generated sequence on the tables?...

Hi If u r having sequence name is dept_seq

create seqeunce dept_seq

start with 10

increment by 10

no chache

no cycle

Then u can use this sequence like this

insert into dept(deptno dname loc) values(dept_seq.nextval <any dname> <any location name>

try this one..

Regards

Dinesh


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
July 04, 2008 15:28:02   #2  
lanka_satya Member Since: January 2008   Contribution: 16    

how to apply the generated sequence on the tables?

Dear friend :
oracle generate sequence numbers with the help of predefined function called nextval.

so if you want insert these generated sequence no you can do using <seq_name>.nextval

for eg:
let us say we have the following table:
sample:
x number
y varchar2(20)

we can generate like this:
create sequence seq_sam start with 1 increment by 1
/
insert into sample values(seq_sam.nextval 'sdsdsf')
/

so you can use like that.............



 
Is this answer useful? Yes | No
March 16, 2009 22:18:10   #3  
gcvpgeek Member Since: March 2009   Contribution: 9    

RE: how to apply the generated sequence on the tables?
Say you are using the seq name temp_seq

CREATE SEQUENCE temp_seq
Start with 5

Increment by 2
maxvalue 999999999999999999999999
nocache
nocycle


Above will create the sequence temp_seq
To use it
INSERT INOT xyz
VALUES (temp_seq.nextval 'oracle')


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape