1 / 11

Oracle Sequence

Oracle Sequence. Perancangan Basis Data. Sequence. What is sequence? How to use Alter Sequence Drop Sequence. What is sequence?. Sequence adalah object yang dapat men- generate unique sequential values . Nilai ini biasanya digunakan sebagai primary ataupun unique keys.

lyle
Download Presentation

Oracle Sequence

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Oracle Sequence Perancangan Basis Data

  2. Sequence • What is sequence? • How to use • Alter Sequence • Drop Sequence

  3. What is sequence? • Sequenceadalah object yang dapat men-generate unique sequential values. Nilaiinibiasanyadigunakansebagaiprimaryataupununique keys. • Dapatdipanggilmenggunakanperintah SQL padapseudocolumnberikut: • CURRVAL: menampilkannilai sequence saatini • NEXTVAL: menampilkannilaiselanjutnya

  4. How to Use – Create Sequence • Schema Sequence:

  5. How to Use – Create Sequence (cont’d) • Membuat Sequence: CREATE SEQUENCE customers_seq START WITH 1000 INCREMENT BY 1 NOCACHE NOCYCLE; • Melihat Sequence: SELECTcustomers_seq.nextval FROM DUAL;

  6. How to Use – Create Sequence (cont’d) • Inserting sequence values into a table: Example  INSERT INTOemployeesVALUES (employees_seq.nextval, 'John', 'Doe', 'jdoe', '555-1212', TO_DATE(SYSDATE), 'PU_CLERK', 2500, null, null, 30); • Reusing the current value of a sequence: Example  • INSERT INTOorders (order_id, order_date, customer_id) VALUES (orders_seq.nextval, TO_DATE(SYSDATE), 106); • INSERT INTO order_items (order_id, line_item_id, product_id) VALUES (orders_seq.currval, 1, 2359); • INSERT INTO order_items (order_id, line_item_id, product_id) VALUES (orders_seq.currval, 2, 3290); • INSERT INTO order_items (order_id, line_item_id, product_id) VALUES (orders_seq.currval, 3, 2381);

  7. Alter Sequence • Schema:

  8. Alter Schema (cont’d) • Deskripsi: ALTER SEQUENCE [schema.] sequence {INCREMENT BY integer | { MAXVALUE integer | NOMAXVALUE } | { MINVALUE integer | NOMINVALUE } | { CYCLE | NOCYCLE } | { CACHE integer | NOCACHE } | { ORDER | NOORDER } } ... ; • Syntax: • ALTER SEQUENCE customers_seq MAXVALUE 1500; • ALTER SEQUENCE customers_seq CYCLE CACHE 5;

  9. Drop Sequence • Schema: • Deskripsi: DROP SEQUENCE [schema.] sequence_name ;

  10. FAQ: • Question:Ketikamembuat sequence, apaarticachedannocache? Contohnya, membuat sequence dengan cache sebesar 20 sebagaiberikut: CREATE SEQUENCE supplier_seq MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 20; dan CREATE SEQUENCE supplier_seq MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE;

  11. FAQ: • Bagaimanamelakukanperubahanlastvaluepada sequence? Sebagaicontoh, sekarangnilaiterakhirnyaadalah 100, dan sequence selanjutnyaadalah 300.

More Related