SlideShare ist ein Scribd-Unternehmen logo
1 von 16
E R Y K B U D I P R A T A M A
T I F L A B A S S I S T A N T – I N F O R M A T I C S E N G I N E E R I N G
ORACLE DATABASE
SEQUENCE
DEFINITION
• Just like tables, views, indexes, and
synonyms, a sequence is a type of database
object.
• Sequences are used to generate unique,
sequential integer values that are used as
primary key values in database tables.
• The sequence of numbers can be
generated in either ascending or
descending order.
SEQUENCE SYNTAX
CREATE SEQUENCE <sequence name>
[INCREMENT BY <number>]
[START WITH <start value number>]
[MAXVALUE <MAXIMUM VLAUE NUMBER>]
[NOMAXVALUE]
[MINVALUE <minimum value number>]
[CYCLE]
[NOCYCLE]
[CACHE <number of sequence value to cache>]
[NOCACHE]
[ORDER]
[NOORDER];
EXAMPLE
CREATE SEQUENCE
order_number_sequence
INCREMENT BY 1
START WITH 1
MAXVALUE 100000000
MINVALUE 1
CYCLE
CACHE 10;
Sequence created.
ACCESSING SEQUENCE VALUES
• Sequence values are generated through the use of
two pseudocolumns named currval and nextval.
• A pseudocolumn behaves like a table column, but
psuedocolumns are not actually stored in a table.
• We can select values from pseudocolumns but
cannot perform manipulations on their values.
• The first time you select the nextval pseudocolumn,
the initial value in the sequence is returned.
• Subsequent selections of the nextval pseudocolumn
will cause the sequence to increment as specified
by the INCREMENT BY clause and will return the
newly generated sequence value.
• The currval pseudocolumn returns the
current value of the sequence, which is the
value returned by the last reference to
nextval.
Example
CREATE TABLE sales_order (
order_number NUMBER(9)
CONSTRAINT pk_sales_order PRIMARY KEY,
order_amount NUMBER(9,2));
• The INSERT commands shown below insert three
rows into the sales_order table. The INSERT
commands reference the
order_number_sequence.nextval pseudocolumn.
INSERT INTO sales_order
VALUES(order_number_sequence.nextval,
155.59 );
INSERT INTO sales_order
VALUES(order_number_sequence.nextval,
450.00 );
INSERT INTO sales_order
VALUES(order_number_sequence.nextval,
16.95);
SELECT * FROM sales_order;
ORDER_NUMBER ORDER_AMOUNT
------------ ------------
1 155.59
2 450
3 16.95
• Use of currval.
CREATE TABLE order_details (
order_number NUMBER(9),
order_row NUMBER(3),
product_desc VARCHAR2(15),
quantity_ordered NUMBER(3),
product_price NUMBER(9,2),
CONSTRAINT pk_order_details
PRIMARY KEY (order_number, order_row),
CONSTRAINT fk_order_number FOREIGN KEY
(order_number) REFERENCES sales_order);
• The order_details table has a FOREIGN
KEY reference to the sales_order table
through the order_number column.
DELETE FROM sales_order;
INSERT INTO sales_order
VALUES ( order_number_sequence.nextval, 200.00 );
INSERT INTO order_details
VALUES ( order_number_sequence.currval, 1, 'End
Table',1, 100.00);
INSERT INTO order_details
VALUES ( order_number_sequence.currval, 2, 'Table
Lamp',2, 50.00);
SELECT * FROM sales_order;
ORDER_NUMBER ORDER_AMOUNT
------------ ------------
5 200
SELECT *
FROM order_details;
ORDER_NUMBER ORDER_ROW PRODUCT_DESC QUANTITY_ORDERED
PRODUCT_PRICE
--------- -------- ---------- ------------- ----------
5 1 End Table 1 100
5 2 Table Lamp 2 50
ALTERING A SEQUENCE
• A sequence is usually altered when it is desirable to
set or eliminate the values of the MINVALUE or
MAXVALUE parameters, or to change the
INCREMENT BY value, or to change the number of
cached sequence numbers.
• The ALTER SEQUENCE command shown here
changes the MAXVALUE of the
order_number_sequence to 200,000,000.
ALTER SEQUENCE order_number_sequence MAXVALUE
200000000;
ALTERING A SEQUENCE
• When specifying a MINVALUE clause, the
specified value should be less than the
MAXVALUE where a sequence generates
ascending numbers.
• In the case of a descending sequence, the
MAXVALUE should be less than the
MINVALUE.
VIEWING SEQUENCE PROPERTIES
• You may need to review the names and
properties of your sequences.
• You can do this by querying the
USER_SEQUENCES system view with a SELECT
command.This view is part of the database's
data dictionary.
SELECT * FROM USER_SEQUENCES;
SEQUENCE_NAME MIN_VAL MAX_VALUE INCRE C O
CACHE_SIZE Last_N
---------------- ------ ---------- ----- -- -- --------
-----
ORDER_NUMBER_SEQUENCE 1 200000000 1 Y N 10 6
DROPPING A SEQUENCE
• DROP SEQUENCE command is used to drop
sequences that need to be recreated or are
no longer needed.
• The general format is shown here along with
an example that drops the
order_number_sequence object.
DROP SEQUENCE <sequence name>;
DROP SEQUENCE order_number_sequence;
Sequence dropped.
Q&A

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
SQL commands
SQL commandsSQL commands
SQL commands
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 
Trigger
TriggerTrigger
Trigger
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Sql Constraints
Sql ConstraintsSql Constraints
Sql Constraints
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Data abstraction in DBMS
Data abstraction in DBMSData abstraction in DBMS
Data abstraction in DBMS
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overriding
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
View of data DBMS
View of data DBMSView of data DBMS
View of data DBMS
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTSDATABASE CONSTRAINTS
DATABASE CONSTRAINTS
 
sql function(ppt)
sql function(ppt)sql function(ppt)
sql function(ppt)
 

Ähnlich wie Oracle Database Sequence

Ähnlich wie Oracle Database Sequence (20)

Si0302 20140320131934
Si0302 20140320131934Si0302 20140320131934
Si0302 20140320131934
 
Sql modifying data - MYSQL part I
Sql modifying data - MYSQL part ISql modifying data - MYSQL part I
Sql modifying data - MYSQL part I
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
Les13
Les13Les13
Les13
 
Sql wksht-3
Sql wksht-3Sql wksht-3
Sql wksht-3
 
MySQL-commands.pdf
MySQL-commands.pdfMySQL-commands.pdf
MySQL-commands.pdf
 
Oracle Advanced SQL and Analytic Functions
Oracle Advanced SQL and Analytic FunctionsOracle Advanced SQL and Analytic Functions
Oracle Advanced SQL and Analytic Functions
 
SQL Keywords
SQL KeywordsSQL Keywords
SQL Keywords
 
Dbms sql-final
Dbms  sql-finalDbms  sql-final
Dbms sql-final
 
Query
QueryQuery
Query
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek SharmaIntroduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
ms-sql-server-150223140402-conversion-gate02.pptx
ms-sql-server-150223140402-conversion-gate02.pptxms-sql-server-150223140402-conversion-gate02.pptx
ms-sql-server-150223140402-conversion-gate02.pptx
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
Sql
SqlSql
Sql
 
Lab
LabLab
Lab
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Oracle basic queries
Oracle basic queriesOracle basic queries
Oracle basic queries
 

Mehr von Eryk Budi Pratama

Ringkasan Standar Kompetensi Data Protection Officer | Agustus 2023 | IODTI
Ringkasan Standar Kompetensi Data Protection Officer | Agustus 2023 | IODTIRingkasan Standar Kompetensi Data Protection Officer | Agustus 2023 | IODTI
Ringkasan Standar Kompetensi Data Protection Officer | Agustus 2023 | IODTIEryk Budi Pratama
 
Implikasi UU PDP terhadap Tata Kelola Data Sektor Kesehatan - Rangkuman UU Pe...
Implikasi UU PDP terhadap Tata Kelola Data Sektor Kesehatan - Rangkuman UU Pe...Implikasi UU PDP terhadap Tata Kelola Data Sektor Kesehatan - Rangkuman UU Pe...
Implikasi UU PDP terhadap Tata Kelola Data Sektor Kesehatan - Rangkuman UU Pe...Eryk Budi Pratama
 
Privacy-ready Data Protection Program Implementation
Privacy-ready Data Protection Program ImplementationPrivacy-ready Data Protection Program Implementation
Privacy-ready Data Protection Program ImplementationEryk Budi Pratama
 
Cybersecurity 101 - Auditing Cyber Security
Cybersecurity 101 - Auditing Cyber SecurityCybersecurity 101 - Auditing Cyber Security
Cybersecurity 101 - Auditing Cyber SecurityEryk Budi Pratama
 
Personal Data Protection in Indonesia
Personal Data Protection in IndonesiaPersonal Data Protection in Indonesia
Personal Data Protection in IndonesiaEryk Budi Pratama
 
Urgensi RUU Perlindungan Data Pribadi
Urgensi RUU Perlindungan Data PribadiUrgensi RUU Perlindungan Data Pribadi
Urgensi RUU Perlindungan Data PribadiEryk Budi Pratama
 
Modern IT Service Management Transformation - ITIL Indonesia
Modern IT Service Management Transformation - ITIL IndonesiaModern IT Service Management Transformation - ITIL Indonesia
Modern IT Service Management Transformation - ITIL IndonesiaEryk Budi Pratama
 
Common Practice in Data Privacy Program Management
Common Practice in Data Privacy Program ManagementCommon Practice in Data Privacy Program Management
Common Practice in Data Privacy Program ManagementEryk Budi Pratama
 
The Rise of Data Ethics and Security - AIDI Webinar
The Rise of Data Ethics and Security - AIDI WebinarThe Rise of Data Ethics and Security - AIDI Webinar
The Rise of Data Ethics and Security - AIDI WebinarEryk Budi Pratama
 
Data Protection Indonesia: Basic Regulation and Technical Aspects_Eryk
Data Protection Indonesia: Basic Regulation and Technical Aspects_ErykData Protection Indonesia: Basic Regulation and Technical Aspects_Eryk
Data Protection Indonesia: Basic Regulation and Technical Aspects_ErykEryk Budi Pratama
 
Data Loss Prevention (DLP) - Fundamental Concept - Eryk
Data Loss Prevention (DLP) - Fundamental Concept - ErykData Loss Prevention (DLP) - Fundamental Concept - Eryk
Data Loss Prevention (DLP) - Fundamental Concept - ErykEryk Budi Pratama
 
Cyber Resilience - Welcoming New Normal - Eryk
Cyber Resilience - Welcoming New Normal - ErykCyber Resilience - Welcoming New Normal - Eryk
Cyber Resilience - Welcoming New Normal - ErykEryk Budi Pratama
 
Enabling Data Governance - Data Trust, Data Ethics, Data Quality
Enabling Data Governance - Data Trust, Data Ethics, Data QualityEnabling Data Governance - Data Trust, Data Ethics, Data Quality
Enabling Data Governance - Data Trust, Data Ethics, Data QualityEryk Budi Pratama
 
Enterprise Cybersecurity: From Strategy to Operating Model
Enterprise Cybersecurity: From Strategy to Operating ModelEnterprise Cybersecurity: From Strategy to Operating Model
Enterprise Cybersecurity: From Strategy to Operating ModelEryk Budi Pratama
 
Blockchain for Accounting & Assurance
Blockchain for Accounting & AssuranceBlockchain for Accounting & Assurance
Blockchain for Accounting & AssuranceEryk Budi Pratama
 
Guardians of Trust: Building Trust in Data & Analytics
Guardians of Trust: Building Trust in Data & AnalyticsGuardians of Trust: Building Trust in Data & Analytics
Guardians of Trust: Building Trust in Data & AnalyticsEryk Budi Pratama
 
The Art of Cloud Auditing - ISACA ID
The Art of Cloud Auditing - ISACA IDThe Art of Cloud Auditing - ISACA ID
The Art of Cloud Auditing - ISACA IDEryk Budi Pratama
 
Cybersecurity Skills in Industry 4.0
Cybersecurity Skills in Industry 4.0Cybersecurity Skills in Industry 4.0
Cybersecurity Skills in Industry 4.0Eryk Budi Pratama
 
Identity & Access Management for Securing DevOps
Identity & Access Management for Securing DevOpsIdentity & Access Management for Securing DevOps
Identity & Access Management for Securing DevOpsEryk Budi Pratama
 
Cybersecurity in Oil & Gas Company
Cybersecurity in Oil & Gas CompanyCybersecurity in Oil & Gas Company
Cybersecurity in Oil & Gas CompanyEryk Budi Pratama
 

Mehr von Eryk Budi Pratama (20)

Ringkasan Standar Kompetensi Data Protection Officer | Agustus 2023 | IODTI
Ringkasan Standar Kompetensi Data Protection Officer | Agustus 2023 | IODTIRingkasan Standar Kompetensi Data Protection Officer | Agustus 2023 | IODTI
Ringkasan Standar Kompetensi Data Protection Officer | Agustus 2023 | IODTI
 
Implikasi UU PDP terhadap Tata Kelola Data Sektor Kesehatan - Rangkuman UU Pe...
Implikasi UU PDP terhadap Tata Kelola Data Sektor Kesehatan - Rangkuman UU Pe...Implikasi UU PDP terhadap Tata Kelola Data Sektor Kesehatan - Rangkuman UU Pe...
Implikasi UU PDP terhadap Tata Kelola Data Sektor Kesehatan - Rangkuman UU Pe...
 
Privacy-ready Data Protection Program Implementation
Privacy-ready Data Protection Program ImplementationPrivacy-ready Data Protection Program Implementation
Privacy-ready Data Protection Program Implementation
 
Cybersecurity 101 - Auditing Cyber Security
Cybersecurity 101 - Auditing Cyber SecurityCybersecurity 101 - Auditing Cyber Security
Cybersecurity 101 - Auditing Cyber Security
 
Personal Data Protection in Indonesia
Personal Data Protection in IndonesiaPersonal Data Protection in Indonesia
Personal Data Protection in Indonesia
 
Urgensi RUU Perlindungan Data Pribadi
Urgensi RUU Perlindungan Data PribadiUrgensi RUU Perlindungan Data Pribadi
Urgensi RUU Perlindungan Data Pribadi
 
Modern IT Service Management Transformation - ITIL Indonesia
Modern IT Service Management Transformation - ITIL IndonesiaModern IT Service Management Transformation - ITIL Indonesia
Modern IT Service Management Transformation - ITIL Indonesia
 
Common Practice in Data Privacy Program Management
Common Practice in Data Privacy Program ManagementCommon Practice in Data Privacy Program Management
Common Practice in Data Privacy Program Management
 
The Rise of Data Ethics and Security - AIDI Webinar
The Rise of Data Ethics and Security - AIDI WebinarThe Rise of Data Ethics and Security - AIDI Webinar
The Rise of Data Ethics and Security - AIDI Webinar
 
Data Protection Indonesia: Basic Regulation and Technical Aspects_Eryk
Data Protection Indonesia: Basic Regulation and Technical Aspects_ErykData Protection Indonesia: Basic Regulation and Technical Aspects_Eryk
Data Protection Indonesia: Basic Regulation and Technical Aspects_Eryk
 
Data Loss Prevention (DLP) - Fundamental Concept - Eryk
Data Loss Prevention (DLP) - Fundamental Concept - ErykData Loss Prevention (DLP) - Fundamental Concept - Eryk
Data Loss Prevention (DLP) - Fundamental Concept - Eryk
 
Cyber Resilience - Welcoming New Normal - Eryk
Cyber Resilience - Welcoming New Normal - ErykCyber Resilience - Welcoming New Normal - Eryk
Cyber Resilience - Welcoming New Normal - Eryk
 
Enabling Data Governance - Data Trust, Data Ethics, Data Quality
Enabling Data Governance - Data Trust, Data Ethics, Data QualityEnabling Data Governance - Data Trust, Data Ethics, Data Quality
Enabling Data Governance - Data Trust, Data Ethics, Data Quality
 
Enterprise Cybersecurity: From Strategy to Operating Model
Enterprise Cybersecurity: From Strategy to Operating ModelEnterprise Cybersecurity: From Strategy to Operating Model
Enterprise Cybersecurity: From Strategy to Operating Model
 
Blockchain for Accounting & Assurance
Blockchain for Accounting & AssuranceBlockchain for Accounting & Assurance
Blockchain for Accounting & Assurance
 
Guardians of Trust: Building Trust in Data & Analytics
Guardians of Trust: Building Trust in Data & AnalyticsGuardians of Trust: Building Trust in Data & Analytics
Guardians of Trust: Building Trust in Data & Analytics
 
The Art of Cloud Auditing - ISACA ID
The Art of Cloud Auditing - ISACA IDThe Art of Cloud Auditing - ISACA ID
The Art of Cloud Auditing - ISACA ID
 
Cybersecurity Skills in Industry 4.0
Cybersecurity Skills in Industry 4.0Cybersecurity Skills in Industry 4.0
Cybersecurity Skills in Industry 4.0
 
Identity & Access Management for Securing DevOps
Identity & Access Management for Securing DevOpsIdentity & Access Management for Securing DevOps
Identity & Access Management for Securing DevOps
 
Cybersecurity in Oil & Gas Company
Cybersecurity in Oil & Gas CompanyCybersecurity in Oil & Gas Company
Cybersecurity in Oil & Gas Company
 

Kürzlich hochgeladen

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Kürzlich hochgeladen (20)

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Oracle Database Sequence

  • 1. E R Y K B U D I P R A T A M A T I F L A B A S S I S T A N T – I N F O R M A T I C S E N G I N E E R I N G ORACLE DATABASE SEQUENCE
  • 2. DEFINITION • Just like tables, views, indexes, and synonyms, a sequence is a type of database object. • Sequences are used to generate unique, sequential integer values that are used as primary key values in database tables. • The sequence of numbers can be generated in either ascending or descending order.
  • 3. SEQUENCE SYNTAX CREATE SEQUENCE <sequence name> [INCREMENT BY <number>] [START WITH <start value number>] [MAXVALUE <MAXIMUM VLAUE NUMBER>] [NOMAXVALUE] [MINVALUE <minimum value number>] [CYCLE] [NOCYCLE] [CACHE <number of sequence value to cache>] [NOCACHE] [ORDER] [NOORDER];
  • 4. EXAMPLE CREATE SEQUENCE order_number_sequence INCREMENT BY 1 START WITH 1 MAXVALUE 100000000 MINVALUE 1 CYCLE CACHE 10; Sequence created.
  • 5. ACCESSING SEQUENCE VALUES • Sequence values are generated through the use of two pseudocolumns named currval and nextval. • A pseudocolumn behaves like a table column, but psuedocolumns are not actually stored in a table. • We can select values from pseudocolumns but cannot perform manipulations on their values. • The first time you select the nextval pseudocolumn, the initial value in the sequence is returned. • Subsequent selections of the nextval pseudocolumn will cause the sequence to increment as specified by the INCREMENT BY clause and will return the newly generated sequence value.
  • 6. • The currval pseudocolumn returns the current value of the sequence, which is the value returned by the last reference to nextval. Example CREATE TABLE sales_order ( order_number NUMBER(9) CONSTRAINT pk_sales_order PRIMARY KEY, order_amount NUMBER(9,2));
  • 7. • The INSERT commands shown below insert three rows into the sales_order table. The INSERT commands reference the order_number_sequence.nextval pseudocolumn. INSERT INTO sales_order VALUES(order_number_sequence.nextval, 155.59 ); INSERT INTO sales_order VALUES(order_number_sequence.nextval, 450.00 ); INSERT INTO sales_order VALUES(order_number_sequence.nextval, 16.95);
  • 8. SELECT * FROM sales_order; ORDER_NUMBER ORDER_AMOUNT ------------ ------------ 1 155.59 2 450 3 16.95
  • 9. • Use of currval. CREATE TABLE order_details ( order_number NUMBER(9), order_row NUMBER(3), product_desc VARCHAR2(15), quantity_ordered NUMBER(3), product_price NUMBER(9,2), CONSTRAINT pk_order_details PRIMARY KEY (order_number, order_row), CONSTRAINT fk_order_number FOREIGN KEY (order_number) REFERENCES sales_order);
  • 10. • The order_details table has a FOREIGN KEY reference to the sales_order table through the order_number column. DELETE FROM sales_order; INSERT INTO sales_order VALUES ( order_number_sequence.nextval, 200.00 ); INSERT INTO order_details VALUES ( order_number_sequence.currval, 1, 'End Table',1, 100.00); INSERT INTO order_details VALUES ( order_number_sequence.currval, 2, 'Table Lamp',2, 50.00);
  • 11. SELECT * FROM sales_order; ORDER_NUMBER ORDER_AMOUNT ------------ ------------ 5 200 SELECT * FROM order_details; ORDER_NUMBER ORDER_ROW PRODUCT_DESC QUANTITY_ORDERED PRODUCT_PRICE --------- -------- ---------- ------------- ---------- 5 1 End Table 1 100 5 2 Table Lamp 2 50
  • 12. ALTERING A SEQUENCE • A sequence is usually altered when it is desirable to set or eliminate the values of the MINVALUE or MAXVALUE parameters, or to change the INCREMENT BY value, or to change the number of cached sequence numbers. • The ALTER SEQUENCE command shown here changes the MAXVALUE of the order_number_sequence to 200,000,000. ALTER SEQUENCE order_number_sequence MAXVALUE 200000000;
  • 13. ALTERING A SEQUENCE • When specifying a MINVALUE clause, the specified value should be less than the MAXVALUE where a sequence generates ascending numbers. • In the case of a descending sequence, the MAXVALUE should be less than the MINVALUE.
  • 14. VIEWING SEQUENCE PROPERTIES • You may need to review the names and properties of your sequences. • You can do this by querying the USER_SEQUENCES system view with a SELECT command.This view is part of the database's data dictionary. SELECT * FROM USER_SEQUENCES; SEQUENCE_NAME MIN_VAL MAX_VALUE INCRE C O CACHE_SIZE Last_N ---------------- ------ ---------- ----- -- -- -------- ----- ORDER_NUMBER_SEQUENCE 1 200000000 1 Y N 10 6
  • 15. DROPPING A SEQUENCE • DROP SEQUENCE command is used to drop sequences that need to be recreated or are no longer needed. • The general format is shown here along with an example that drops the order_number_sequence object. DROP SEQUENCE <sequence name>; DROP SEQUENCE order_number_sequence; Sequence dropped.
  • 16. Q&A