Auto number on Primary Key
755461Feb 19 2011 — edited Mar 9 2011Hello All,
I have set up a schema using a DDL script in Oracle 10g. I am linking this through to a Visual Basic 2008 fron end. The connection is fine.
My database of is for a car hire company project.
I need to know how to create an auto increment for a primary key field, like Access does.
For example here is my table structure for my Rental_Payment table.
-- TABLE RENTAL_PAYMENT
CREATE TABLE RENTAL_PAYMENT (
PAYMENTNO NUMBER NOT NULL,
CARDNO NUMBER NOT NULL,
AMOUNT NUMBER NOT NULL,
CARD_TYPE CHAR(20 ) NOT NULL
)
/
-- ADD KEYS FOR TABLE RENTAL_PAYMENT
ALTER TABLE RENTAL_PAYMENT ADD CONSTRAINT KEY6 PRIMARY KEY ( PAYMENTNO )
/
So for example the first record would appear as:
PAYMENTNO CARDNO AMOUNT CARD_TYPE
======== ===== ====== =======
01
I would then enter values and the next payment number would be 02 etc.
PAYMENTNO CARDNO AMOUNT CARD_TYPE
======== ===== ====== =======
01 123412 £40.00 VISA
02
Visual Basic will usually have a star (*) beside a new entry field so 02 will be
| |123412|£40.00|VISA
*|02 | | |
etc........
Thankyou in advance,
OracleTechie