|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
Thanks for the help. Looks like I got some homework to do on sequences & triggers.;-)
|
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Create table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|