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:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...