Wednesday, April 26, 2006

Script for Autoincrement : Oracle 10

DROP TABLE PROFILE;
DROP SEQUENCE AutoIncrement;
DROP TRIGGER PROFILE_TRIGGER;

CREATE TABLE PROFILE
(

ID NUMBER PRIMARY KEY,
PROFILENAME VARCHAR2(25),
FONT VARCHAR2(25),
DEFAULT_PADDING NUMBER,
FONT_SIZE NUMBER
);
CREATE SEQUENCE AUTOINCREMENT
start with 1
increment by 1
nomaxvalue;
CREATE TRIGGER PROFILE_TRIGGER
BEFORE INSERT
ON PROFILE
REFERENCING NEW AS NEW
FOR EACH ROW BEGIN
SELECT AUTOINCREMENT.nextval INTO :NEW.ID FROM dual;
END;

INSERT INTO PROFILE(PROFILENAME) VALUES('some value one');
INSERT INTO PROFILE(PROFILENAME) VALUES('some value two');

SELECT * FROM PROFILE;

No comments:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...