Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 10th, 2003, 05:53 PM
iDezzign iDezzign is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Utah
Posts: 20 iDezzign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 35 m 47 sec
Reputation Power: 0
Create table

My first time in oracle. Im trying to create tables. Im using dbvisualizer. (i love that) What I cant get is how to auto increment my primary key fields.
This project was originaly in MySQL, easy enough to auto_increment there. How do I do it in dbvisualzer?

Reply With Quote
  #2  
Old December 11th, 2003, 08:42 AM
Dan Drillich Dan Drillich is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 68 Dan Drillich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
The best way to do it in Oracle is via a sequence:

create sequence table_pk_seq;

and then in the insert statement:

insert into <table> values (table_pk_seq.nextval, ......);

Good Luck,
Dan

Reply With Quote
  #3  
Old December 11th, 2003, 09:12 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
I dont have any idea about dbvisualizer, however, Oracle allows you to generate auto number series by creating SEQUENCE, these auto generated numbers can be used in your table at the time of inserting rows. Oracle gives you two pseudo column NEXTVAL and CURRVAL to get next vale and current value of the sequence repectively. I give you an idea, how can you do this:

First create the sequence:

SQL>CREATE SEQUENCE emp_seq
start with 1
increament by 1
nomaxvalue
nocycle
nocache
;

Now you can use this auto generated value in the emp table as follows:

insert into emp (empno, ename, sal, deptno)
values (seq_emp.nextval, 'Oracle Guru', 2300, 10)
/

How can you do this by dbvisualizer?, it's you home work.

Regards

Reply With Quote
  #4  
Old December 11th, 2003, 04:21 PM
iDezzign iDezzign is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Utah
Posts: 20 iDezzign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 35 m 47 sec
Reputation Power: 0
Thanks for the help. Looks like I got some homework to do on sequences & triggers.;-)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Create table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway