SlideShare a Scribd company logo
1 of 5
1DR. GIRIJA NARASIMHAN
Part 7- Alter Sequence
2
DR. GIRIJA NARASIMHAN
Use the ALTER SEQUENCE statement to change the
increment,
minimum and maximum values,
cached numbers,
and behavior of an existing sequence.
This statement affects only future sequence numbers.
SQL> alter sequence seq1 start with 1001;
alter sequence seq1 start with 1001
*
ERROR at line 1:
ORA-02283: cannot alter starting sequence number
SQL> alter sequence seq1 increment by 2;
Sequence altered.
SQL> select seq1.nextval from dual;
NEXTVAL
----------
1001
SQL> select seq1.nextval from dual;
NEXTVAL
----------
1003
•If you change the INCREMENT BY value
before the first invocation of NEXTVAL, some
sequence numbers will be skipped.
•Therefore, if you want to retain the original
START WITH value, you must drop the
sequence and re-create it with the original
START WITH value and the new INCREMENT BY
value.
create sequence seq1
START WITH 1000
INCREMENT BY 1
NOCACHE
maxvalue 1005
minvalue 1000
cycle;
DR. GIRIJA NARASIMHAN
Oracle Database performs some validations. For example, a new
MAXVALUE cannot be imposed that is less than the current
sequence number.
SQL> select seq1.currval from dual;
CURRVAL
----------
1003
SQL> alter sequence seq1 maxvalue 1002;
alter sequence seq1 maxvalue 1002
*
ERROR at line 1:
ORA-04009: MAXVALUE cannot be made to be less than the current value
DR. GIRIJA NARASIMHAN
http://www.slideshare.net/nbgirija

More Related Content

Viewers also liked

Viewers also liked (13)

normalization
normalizationnormalization
normalization
 
Part 26 lov
Part 26 lovPart 26 lov
Part 26 lov
 
Rel algebra set theory girija
Rel algebra set theory girijaRel algebra set theory girija
Rel algebra set theory girija
 
Snowflake
SnowflakeSnowflake
Snowflake
 
Part 16 ALERT USING ORACLE 10G FORM BUILDER
Part 16 ALERT USING ORACLE 10G FORM BUILDERPart 16 ALERT USING ORACLE 10G FORM BUILDER
Part 16 ALERT USING ORACLE 10G FORM BUILDER
 
அழகு வெள்ளம்- Adi shankara, soundarya lahari tamil version
அழகு வெள்ளம்- Adi shankara, soundarya lahari  tamil versionஅழகு வெள்ளம்- Adi shankara, soundarya lahari  tamil version
அழகு வெள்ளம்- Adi shankara, soundarya lahari tamil version
 
Rel algebra girija -product
Rel algebra girija -productRel algebra girija -product
Rel algebra girija -product
 
Part 12 tab canvas
Part 12 tab canvasPart 12 tab canvas
Part 12 tab canvas
 
Part 27 current date
Part 27 current datePart 27 current date
Part 27 current date
 
Part 12 dmltype$$
Part 12 dmltype$$Part 12 dmltype$$
Part 12 dmltype$$
 
Part 21 for update
Part 21 for updatePart 21 for update
Part 21 for update
 
Part 5 cube
Part 5 cubePart 5 cube
Part 5 cube
 
Part2 sql model-dimension by
Part2 sql model-dimension byPart2 sql model-dimension by
Part2 sql model-dimension by
 

Similar to Part 7 alter sequence modified (6)

Oracle 11g new features for developers
Oracle 11g new features for developersOracle 11g new features for developers
Oracle 11g new features for developers
 
Part 3 drop sequence nextval,currval
Part 3 drop sequence nextval,currvalPart 3 drop sequence nextval,currval
Part 3 drop sequence nextval,currval
 
Sequences
SequencesSequences
Sequences
 
DB2-SQL Part-2
DB2-SQL Part-2DB2-SQL Part-2
DB2-SQL Part-2
 
Sequencereset
SequenceresetSequencereset
Sequencereset
 
It6312 dbms lab-ex2
It6312 dbms lab-ex2It6312 dbms lab-ex2
It6312 dbms lab-ex2
 

More from Girija Muscut

More from Girija Muscut (20)

Tamil Nalvar
Tamil Nalvar Tamil Nalvar
Tamil Nalvar
 
Visualization using Tableau
Visualization using TableauVisualization using Tableau
Visualization using Tableau
 
Introduction to ml
Introduction to mlIntroduction to ml
Introduction to ml
 
Effective Visualization with Tableau
Effective Visualization with TableauEffective Visualization with Tableau
Effective Visualization with Tableau
 
Guruvayoor song with audio-Udayasthamana puja
Guruvayoor song with audio-Udayasthamana puja Guruvayoor song with audio-Udayasthamana puja
Guruvayoor song with audio-Udayasthamana puja
 
Lakshmi lalli with audio
Lakshmi lalli with audioLakshmi lalli with audio
Lakshmi lalli with audio
 
Bagyada laskhmi purandara dasa
Bagyada laskhmi purandara dasaBagyada laskhmi purandara dasa
Bagyada laskhmi purandara dasa
 
Lakshmi lalli
Lakshmi lalliLakshmi lalli
Lakshmi lalli
 
Amba nee irangaayenil - papanasam sivan song
Amba nee irangaayenil - papanasam sivan songAmba nee irangaayenil - papanasam sivan song
Amba nee irangaayenil - papanasam sivan song
 
Mahalakshmi jagan madha - papanasm sivan tamil song
Mahalakshmi jagan madha  - papanasm sivan tamil songMahalakshmi jagan madha  - papanasm sivan tamil song
Mahalakshmi jagan madha - papanasm sivan tamil song
 
Sowbhagayaha laskhmi varuvai nee tamil song
Sowbhagayaha laskhmi varuvai nee tamil songSowbhagayaha laskhmi varuvai nee tamil song
Sowbhagayaha laskhmi varuvai nee tamil song
 
Bega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
Bega baro Bega baro Neela Megha Varna-Vadhiraja TheerthaBega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
Bega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
 
Rama Nama Bhajan
Rama Nama BhajanRama Nama Bhajan
Rama Nama Bhajan
 
Saratha devi song 1
Saratha devi song 1Saratha devi song 1
Saratha devi song 1
 
Saraswathi bhajan 1 with tamil meaning
Saraswathi bhajan 1 with tamil meaningSaraswathi bhajan 1 with tamil meaning
Saraswathi bhajan 1 with tamil meaning
 
Aneyu karadare -Purandara Dasar.
Aneyu karadare -Purandara Dasar.Aneyu karadare -Purandara Dasar.
Aneyu karadare -Purandara Dasar.
 
Maithriam Bhajatha with tamil meaning (lyrics)
Maithriam Bhajatha with tamil meaning (lyrics)Maithriam Bhajatha with tamil meaning (lyrics)
Maithriam Bhajatha with tamil meaning (lyrics)
 
Unit 4 scd2-exercise 1-solution
Unit 4 scd2-exercise 1-solutionUnit 4 scd2-exercise 1-solution
Unit 4 scd2-exercise 1-solution
 
Unit 2 - Slowly Changing Dimension Type 1 (SCD1) (insert)
Unit 2  - Slowly Changing Dimension Type 1 (SCD1) (insert)Unit 2  - Slowly Changing Dimension Type 1 (SCD1) (insert)
Unit 2 - Slowly Changing Dimension Type 1 (SCD1) (insert)
 
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and updateSlowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 

Part 7 alter sequence modified

  • 1. 1DR. GIRIJA NARASIMHAN Part 7- Alter Sequence
  • 2. 2 DR. GIRIJA NARASIMHAN Use the ALTER SEQUENCE statement to change the increment, minimum and maximum values, cached numbers, and behavior of an existing sequence. This statement affects only future sequence numbers.
  • 3. SQL> alter sequence seq1 start with 1001; alter sequence seq1 start with 1001 * ERROR at line 1: ORA-02283: cannot alter starting sequence number SQL> alter sequence seq1 increment by 2; Sequence altered. SQL> select seq1.nextval from dual; NEXTVAL ---------- 1001 SQL> select seq1.nextval from dual; NEXTVAL ---------- 1003 •If you change the INCREMENT BY value before the first invocation of NEXTVAL, some sequence numbers will be skipped. •Therefore, if you want to retain the original START WITH value, you must drop the sequence and re-create it with the original START WITH value and the new INCREMENT BY value. create sequence seq1 START WITH 1000 INCREMENT BY 1 NOCACHE maxvalue 1005 minvalue 1000 cycle; DR. GIRIJA NARASIMHAN
  • 4. Oracle Database performs some validations. For example, a new MAXVALUE cannot be imposed that is less than the current sequence number. SQL> select seq1.currval from dual; CURRVAL ---------- 1003 SQL> alter sequence seq1 maxvalue 1002; alter sequence seq1 maxvalue 1002 * ERROR at line 1: ORA-04009: MAXVALUE cannot be made to be less than the current value DR. GIRIJA NARASIMHAN