SlideShare una empresa de Scribd logo
1 de 23
ther Database Object
http://ecomputernotes.com
Objectives
After completing this lesson, you should be able to
do the following:
" Create, maintain, and use sequences
" Create and maintain indexes
" Create private and public synonyms
http://ecomputernotes.com
Database Objects
Object Description
Basic unit of storage; composed of rowsTable
and columns
View Logically represents subsets of data from
one or more tables
Generates primary key valuesSequence
Index Improves the performance of some queries
Synonym Alternative name for an object
http://ecomputernotes.com
What Is a Sequence?
A sequence:
" Automatically generates unique numbers
" Is a sharable object
" Is typically used to create a primary key value
" Replaces application code
" Speeds up the efficiency of accessing sequence
values when cached in memory
http://ecomputernotes.com
The CREATE SEQUENCE Statement Syntax
Define a sequence to generate sequential numbers
automatically:
CREATE SEQUENCE sequence
[INCREMENT BY n]
[START WITH n]
[START WITH n]
[{MAXVALUE n | NOMAXVALUE}]
[{MINVALUE n | NOMINVALUE}]
[{CYCLE | NOCYCLE}]
[{CACHE n | NOCACHE}];
http://ecomputernotes.com
Creating a Sequence
" Create a sequence named DEPT_DEPTID_SEQ to be
used for the primary key of the DEPARTMENTS table.
" Do not use the CYCLE option.
CREATE SEQUENCE dept_deptid_seq
INCREMENT BY 10
START WITH 120
START WITH 120
MAXVALUE 9999
NOCACHE
NOCYCLE;
Sequence created.
http://ecomputernotes.com
Confirming Sequences
" Verify your sequence values in the
USER_SEQUENCES data dictionary table.
SELECT sequence_name, min_value, max_value,
increment_by, last_number
FRO M user_sequences;
" The LAST_NUMBER column displays the next
available sequence number if NOCACHE is
specified.
http://ecomputernotes.com
NEXTVAL and CURRVAL Pseudocolumns
" NEXTVAL returns the next available sequence
value. It returns a unique value every time it is
referenced, even for different users.
" CURRVAL obtains the current sequence value.
" NEXTVAL must be issued for that sequence before
CURRVAL contains a value.
http://ecomputernotes.com
Using a Sequence
" Insert a new department named ³Support´ in
location ID 2500.
INSERT INTO departments(department_id,
department_name, location_id)
VALUES (dept_deptid_seq.NEXTVAL,
'Support', 2500);
1 row created.
" View the current value for the DEPT_DEPTID_SEQ
sequence.
SELECT dept_deptid_seq.CURRVAL
FROM dual;
http://ecomputernotes.com
Using a Sequence
"Caching sequence values in memory gives faster
access to those values.
"Gaps in sequence values can occur when:
A rollback occurs
The system crashes
A sequence is used in another table
" If the sequence was created with NOCACHE, view
the next available value, by querying the
USER_SEQUENCES table.
http://ecomputernotes.com
Modifying a Sequence
Change the increment value, maximum value,
minimum value, cycle option, or cache option.
ALTER SEQUENCE dept_deptid_seq
INCREMENT BY 20
MAXVALUE 999999
NOCACHE
NOCYCLE;
Sequence altered.
http://ecomputernotes.com
Guidelines for Modifying
a Sequence
" You must be the owner or have the ALTER
privilege for the sequence.
" Only future sequence numbers are affected.
" The sequence must be dropped and
re-created to restart the sequence at a different
number.
" Some validation is performed.
Removing a Sequence
"Remove a sequence from the data dictionary by
using the DROP SEQUENCE statement. "Once
removed, the sequence can no longer be
referenced.
DROP SEQUENCE dept_deptid_seq;
Sequence dropped.
What is an Index?
An index:
" Is a schema object
" Is used by the Oracle server to speed up the
retrieval of rows by using a pointer
" Can reduce disk I/O by using a rapid path access
method to locate data quickly
" Is independent of the table it indexes
" Is used and maintained automatically by the
Oracle server
How Are Indexes Created?
"Automatically: A unique index is created
automatically when you define a PRIMARY KEY or
UNIQUE constraint in a table definition. "Manually:
Users can create nonunique indexes on
columns to speed up access to the rows.
Creating an Index
"Create an index on one or more columns.
CREATE INDEXindex
ON table (column[, column]...);
"Improve the speed of query access to the
LAST_NAME column in the EMPLOYEES table.
CREATE INDEX emp_last_name_idx
ON employees(last_name);
Index created.
When to Create an Index
You should create an index if:
" A column contains a wide range of values
" A column contains a large number of null values
" One or more columns are frequently used together
in a WHERE clause or a join condition "The table is
large and most queries are expected
to retrieve less than 2 to 4 percent of the rows
When Not to Create an Index
It is usually not worth creating an index if:
" The table is small
" The columns are not often used as a condition in
the query
" Most queries are expected to retrieve more than 2
to 4 percent of the rows in the table
" The table is updated frequently
" The indexed columns are referenced as part of an
expression
Confirming Indexes
"The USER_INDEXES data dictionary view contains the
name of the index and its uniqueness. "The
USER_IND_COLUMNS view contains the index
name, the table name, and the column name.
SELECT ic.index_name, ic.column_name,
ic.column_position col_pos,ix.uniqueness
FRO M user_indexes ix, user_ind_columns ic
WHERE ic.index_name = ix.index_name
AND ic.table_name = 'EMPLOYEES';
Function-Based Indexes
"A function-based index is an index based on
expressions.
"The index expression is built from table columns,
constants, SQL functions, and user-defined
functions.
CREATE INDEX upper_dept_name_idx ON
departments(UPPER(department_name));
Index created.
SELECT *
FROM departments
WHERE UPPER(department_name) = 'SALES';
Removing an Index
"Remove an index from the data dictionary by
using the DROP INDEX command.
DROP INDEX index;
"Remove the UPPER_LAST_NAME_IDX index from
the data dictionary.
DROP INDEX upper_last_name_idx;
Index dropped.
"To drop an index, you must be the owner of the
index or have the DROP ANY INDEX privilege.
Synonyms
Simplify access to objects by creating a synonym
(another name for an object). With synonyms, you can:
" Ease referring to a table owned by another user
"Shorten lengthy object names
CREATE [PUBLIC] SYNONY M synonym
FOR object;
Creating and Removing Synonyms
"Create a shortened name for the
DEPT_SUM_VU view.
CREATE SYNONYM d_sum
FOR dept_sum_vu;
Synonym Created.
" Drop a synonym.
DROP SYNONYM d_sum;
Synonym dropped.

Más contenido relacionado

La actualidad más candente

La actualidad más candente (15)

Web Application Security 101 - 14 Data Validation
Web Application Security 101 - 14 Data ValidationWeb Application Security 101 - 14 Data Validation
Web Application Security 101 - 14 Data Validation
 
ASP.Net Presentation Part2
ASP.Net Presentation Part2ASP.Net Presentation Part2
ASP.Net Presentation Part2
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
Sql views
Sql viewsSql views
Sql views
 
Mule system properties
Mule system propertiesMule system properties
Mule system properties
 
How to Create and Load Model in Laravel
How to Create and Load Model in LaravelHow to Create and Load Model in Laravel
How to Create and Load Model in Laravel
 
IR SQLite Session #1
IR SQLite Session #1IR SQLite Session #1
IR SQLite Session #1
 
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
 
How mysql choose the execution plan
How mysql choose the execution planHow mysql choose the execution plan
How mysql choose the execution plan
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
 
Database index by Reema Gajjar
Database index by Reema GajjarDatabase index by Reema Gajjar
Database index by Reema Gajjar
 
Scalar user defined function in sap hana
Scalar user defined function in sap hanaScalar user defined function in sap hana
Scalar user defined function in sap hana
 
Ajax
AjaxAjax
Ajax
 
CIS 282 Final Review
CIS 282 Final ReviewCIS 282 Final Review
CIS 282 Final Review
 
JavaStates Simple Tutorial
JavaStates Simple TutorialJavaStates Simple Tutorial
JavaStates Simple Tutorial
 

Destacado

computer notes - Processes and process management
computer notes - Processes and process managementcomputer notes - Processes and process management
computer notes - Processes and process managementecomputernotes
 
computer notes - Circular list
computer notes - Circular listcomputer notes - Circular list
computer notes - Circular listecomputernotes
 
Computer notes - data structures
Computer notes - data structuresComputer notes - data structures
Computer notes - data structuresecomputernotes
 
computer notes - Stack
computer notes - Stackcomputer notes - Stack
computer notes - Stackecomputernotes
 
computer notes - File systems and management
computer notes - File systems and managementcomputer notes - File systems and management
computer notes - File systems and managementecomputernotes
 
e computer notes - Operations on binary tree
e computer notes - Operations on binary treee computer notes - Operations on binary tree
e computer notes - Operations on binary treeecomputernotes
 
computer notes - Priority queue
computer notes -  Priority queuecomputer notes -  Priority queue
computer notes - Priority queueecomputernotes
 
Computer notes - Reference Variables –II
Computer notes  - Reference Variables –IIComputer notes  - Reference Variables –II
Computer notes - Reference Variables –IIecomputernotes
 
Computer notes - Maze Generator
Computer notes - Maze GeneratorComputer notes - Maze Generator
Computer notes - Maze Generatorecomputernotes
 
Computer notes - singleRightRotation
Computer notes   - singleRightRotationComputer notes   - singleRightRotation
Computer notes - singleRightRotationecomputernotes
 
computer notes - Linked list
computer notes - Linked listcomputer notes - Linked list
computer notes - Linked listecomputernotes
 
Computer notes - Analysis of Union
Computer notes  - Analysis of Union Computer notes  - Analysis of Union
Computer notes - Analysis of Union ecomputernotes
 
computer notes - Introduction to operating system
computer notes - Introduction to operating systemcomputer notes - Introduction to operating system
computer notes - Introduction to operating systemecomputernotes
 

Destacado (13)

computer notes - Processes and process management
computer notes - Processes and process managementcomputer notes - Processes and process management
computer notes - Processes and process management
 
computer notes - Circular list
computer notes - Circular listcomputer notes - Circular list
computer notes - Circular list
 
Computer notes - data structures
Computer notes - data structuresComputer notes - data structures
Computer notes - data structures
 
computer notes - Stack
computer notes - Stackcomputer notes - Stack
computer notes - Stack
 
computer notes - File systems and management
computer notes - File systems and managementcomputer notes - File systems and management
computer notes - File systems and management
 
e computer notes - Operations on binary tree
e computer notes - Operations on binary treee computer notes - Operations on binary tree
e computer notes - Operations on binary tree
 
computer notes - Priority queue
computer notes -  Priority queuecomputer notes -  Priority queue
computer notes - Priority queue
 
Computer notes - Reference Variables –II
Computer notes  - Reference Variables –IIComputer notes  - Reference Variables –II
Computer notes - Reference Variables –II
 
Computer notes - Maze Generator
Computer notes - Maze GeneratorComputer notes - Maze Generator
Computer notes - Maze Generator
 
Computer notes - singleRightRotation
Computer notes   - singleRightRotationComputer notes   - singleRightRotation
Computer notes - singleRightRotation
 
computer notes - Linked list
computer notes - Linked listcomputer notes - Linked list
computer notes - Linked list
 
Computer notes - Analysis of Union
Computer notes  - Analysis of Union Computer notes  - Analysis of Union
Computer notes - Analysis of Union
 
computer notes - Introduction to operating system
computer notes - Introduction to operating systemcomputer notes - Introduction to operating system
computer notes - Introduction to operating system
 

Similar a e computer notes - Other database objects

Similar a e computer notes - Other database objects (20)

Les12
Les12Les12
Les12
 
Les13
Les13Les13
Les13
 
Database Objects
Database ObjectsDatabase Objects
Database Objects
 
[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps
 
Les10
Les10Les10
Les10
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
 
SQL WORKSHOP::Lecture 13
SQL WORKSHOP::Lecture 13SQL WORKSHOP::Lecture 13
SQL WORKSHOP::Lecture 13
 
chap13.ppt
chap13.pptchap13.ppt
chap13.ppt
 
Creating other schema objects
Creating other schema objectsCreating other schema objects
Creating other schema objects
 
Local Storage
Local StorageLocal Storage
Local Storage
 
Android database tutorial
Android database tutorialAndroid database tutorial
Android database tutorial
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
 
Sequences and indexes
Sequences and indexesSequences and indexes
Sequences and indexes
 
Les13[1]Other Database Objects
Les13[1]Other Database ObjectsLes13[1]Other Database Objects
Les13[1]Other Database Objects
 
7. SQL.pptx
7. SQL.pptx7. SQL.pptx
7. SQL.pptx
 
PHP and Mysql
PHP and MysqlPHP and Mysql
PHP and Mysql
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007
 
Learn PHP Lacture2
Learn PHP Lacture2Learn PHP Lacture2
Learn PHP Lacture2
 
PHP - Getting good with MySQL part II
 PHP - Getting good with MySQL part II PHP - Getting good with MySQL part II
PHP - Getting good with MySQL part II
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 

Más de ecomputernotes

computer notes - Data Structures - 30
computer notes - Data Structures - 30computer notes - Data Structures - 30
computer notes - Data Structures - 30ecomputernotes
 
computer notes - Data Structures - 39
computer notes - Data Structures - 39computer notes - Data Structures - 39
computer notes - Data Structures - 39ecomputernotes
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11ecomputernotes
 
computer notes - Data Structures - 20
computer notes - Data Structures - 20computer notes - Data Structures - 20
computer notes - Data Structures - 20ecomputernotes
 
computer notes - Data Structures - 15
computer notes - Data Structures - 15computer notes - Data Structures - 15
computer notes - Data Structures - 15ecomputernotes
 
Computer notes - Including Constraints
Computer notes - Including ConstraintsComputer notes - Including Constraints
Computer notes - Including Constraintsecomputernotes
 
Computer notes - Date time Functions
Computer notes - Date time FunctionsComputer notes - Date time Functions
Computer notes - Date time Functionsecomputernotes
 
Computer notes - Subqueries
Computer notes - SubqueriesComputer notes - Subqueries
Computer notes - Subqueriesecomputernotes
 
Computer notes - Other Database Objects
Computer notes - Other Database ObjectsComputer notes - Other Database Objects
Computer notes - Other Database Objectsecomputernotes
 
computer notes - Data Structures - 28
computer notes - Data Structures - 28computer notes - Data Structures - 28
computer notes - Data Structures - 28ecomputernotes
 
computer notes - Data Structures - 19
computer notes - Data Structures - 19computer notes - Data Structures - 19
computer notes - Data Structures - 19ecomputernotes
 
computer notes - Data Structures - 31
computer notes - Data Structures - 31computer notes - Data Structures - 31
computer notes - Data Structures - 31ecomputernotes
 
computer notes - Data Structures - 4
computer notes - Data Structures - 4computer notes - Data Structures - 4
computer notes - Data Structures - 4ecomputernotes
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13ecomputernotes
 
Computer notes - Advanced Subqueries
Computer notes -   Advanced SubqueriesComputer notes -   Advanced Subqueries
Computer notes - Advanced Subqueriesecomputernotes
 
Computer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group FunctionsComputer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group Functionsecomputernotes
 
computer notes - Data Structures - 16
computer notes - Data Structures - 16computer notes - Data Structures - 16
computer notes - Data Structures - 16ecomputernotes
 
computer notes - Data Structures - 22
computer notes - Data Structures - 22computer notes - Data Structures - 22
computer notes - Data Structures - 22ecomputernotes
 
computer notes - Data Structures - 35
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35ecomputernotes
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36ecomputernotes
 

Más de ecomputernotes (20)

computer notes - Data Structures - 30
computer notes - Data Structures - 30computer notes - Data Structures - 30
computer notes - Data Structures - 30
 
computer notes - Data Structures - 39
computer notes - Data Structures - 39computer notes - Data Structures - 39
computer notes - Data Structures - 39
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11
 
computer notes - Data Structures - 20
computer notes - Data Structures - 20computer notes - Data Structures - 20
computer notes - Data Structures - 20
 
computer notes - Data Structures - 15
computer notes - Data Structures - 15computer notes - Data Structures - 15
computer notes - Data Structures - 15
 
Computer notes - Including Constraints
Computer notes - Including ConstraintsComputer notes - Including Constraints
Computer notes - Including Constraints
 
Computer notes - Date time Functions
Computer notes - Date time FunctionsComputer notes - Date time Functions
Computer notes - Date time Functions
 
Computer notes - Subqueries
Computer notes - SubqueriesComputer notes - Subqueries
Computer notes - Subqueries
 
Computer notes - Other Database Objects
Computer notes - Other Database ObjectsComputer notes - Other Database Objects
Computer notes - Other Database Objects
 
computer notes - Data Structures - 28
computer notes - Data Structures - 28computer notes - Data Structures - 28
computer notes - Data Structures - 28
 
computer notes - Data Structures - 19
computer notes - Data Structures - 19computer notes - Data Structures - 19
computer notes - Data Structures - 19
 
computer notes - Data Structures - 31
computer notes - Data Structures - 31computer notes - Data Structures - 31
computer notes - Data Structures - 31
 
computer notes - Data Structures - 4
computer notes - Data Structures - 4computer notes - Data Structures - 4
computer notes - Data Structures - 4
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
 
Computer notes - Advanced Subqueries
Computer notes -   Advanced SubqueriesComputer notes -   Advanced Subqueries
Computer notes - Advanced Subqueries
 
Computer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group FunctionsComputer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group Functions
 
computer notes - Data Structures - 16
computer notes - Data Structures - 16computer notes - Data Structures - 16
computer notes - Data Structures - 16
 
computer notes - Data Structures - 22
computer notes - Data Structures - 22computer notes - Data Structures - 22
computer notes - Data Structures - 22
 
computer notes - Data Structures - 35
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36
 

Último

ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesashishpaul799
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17Celine George
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Denish Jangid
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxCeline George
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff17thcssbs2
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Celine George
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
The Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfThe Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfdm4ashexcelr
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45MysoreMuleSoftMeetup
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdfVikramadityaRaj
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxCapitolTechU
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptxmansk2
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptxmanishaJyala2
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryEugene Lysak
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPragya - UEM Kolkata Quiz Club
 

Último (20)

ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
The Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfThe Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdf
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
 

e computer notes - Other database objects

  • 2. Objectives After completing this lesson, you should be able to do the following: " Create, maintain, and use sequences " Create and maintain indexes " Create private and public synonyms http://ecomputernotes.com
  • 3. Database Objects Object Description Basic unit of storage; composed of rowsTable and columns View Logically represents subsets of data from one or more tables Generates primary key valuesSequence Index Improves the performance of some queries Synonym Alternative name for an object http://ecomputernotes.com
  • 4. What Is a Sequence? A sequence: " Automatically generates unique numbers " Is a sharable object " Is typically used to create a primary key value " Replaces application code " Speeds up the efficiency of accessing sequence values when cached in memory http://ecomputernotes.com
  • 5. The CREATE SEQUENCE Statement Syntax Define a sequence to generate sequential numbers automatically: CREATE SEQUENCE sequence [INCREMENT BY n] [START WITH n] [START WITH n] [{MAXVALUE n | NOMAXVALUE}] [{MINVALUE n | NOMINVALUE}] [{CYCLE | NOCYCLE}] [{CACHE n | NOCACHE}]; http://ecomputernotes.com
  • 6. Creating a Sequence " Create a sequence named DEPT_DEPTID_SEQ to be used for the primary key of the DEPARTMENTS table. " Do not use the CYCLE option. CREATE SEQUENCE dept_deptid_seq INCREMENT BY 10 START WITH 120 START WITH 120 MAXVALUE 9999 NOCACHE NOCYCLE; Sequence created. http://ecomputernotes.com
  • 7. Confirming Sequences " Verify your sequence values in the USER_SEQUENCES data dictionary table. SELECT sequence_name, min_value, max_value, increment_by, last_number FRO M user_sequences; " The LAST_NUMBER column displays the next available sequence number if NOCACHE is specified. http://ecomputernotes.com
  • 8. NEXTVAL and CURRVAL Pseudocolumns " NEXTVAL returns the next available sequence value. It returns a unique value every time it is referenced, even for different users. " CURRVAL obtains the current sequence value. " NEXTVAL must be issued for that sequence before CURRVAL contains a value. http://ecomputernotes.com
  • 9. Using a Sequence " Insert a new department named ³Support´ in location ID 2500. INSERT INTO departments(department_id, department_name, location_id) VALUES (dept_deptid_seq.NEXTVAL, 'Support', 2500); 1 row created. " View the current value for the DEPT_DEPTID_SEQ sequence. SELECT dept_deptid_seq.CURRVAL FROM dual; http://ecomputernotes.com
  • 10. Using a Sequence "Caching sequence values in memory gives faster access to those values. "Gaps in sequence values can occur when: A rollback occurs The system crashes A sequence is used in another table " If the sequence was created with NOCACHE, view the next available value, by querying the USER_SEQUENCES table. http://ecomputernotes.com
  • 11. Modifying a Sequence Change the increment value, maximum value, minimum value, cycle option, or cache option. ALTER SEQUENCE dept_deptid_seq INCREMENT BY 20 MAXVALUE 999999 NOCACHE NOCYCLE; Sequence altered. http://ecomputernotes.com
  • 12. Guidelines for Modifying a Sequence " You must be the owner or have the ALTER privilege for the sequence. " Only future sequence numbers are affected. " The sequence must be dropped and re-created to restart the sequence at a different number. " Some validation is performed.
  • 13. Removing a Sequence "Remove a sequence from the data dictionary by using the DROP SEQUENCE statement. "Once removed, the sequence can no longer be referenced. DROP SEQUENCE dept_deptid_seq; Sequence dropped.
  • 14. What is an Index? An index: " Is a schema object " Is used by the Oracle server to speed up the retrieval of rows by using a pointer " Can reduce disk I/O by using a rapid path access method to locate data quickly " Is independent of the table it indexes " Is used and maintained automatically by the Oracle server
  • 15. How Are Indexes Created? "Automatically: A unique index is created automatically when you define a PRIMARY KEY or UNIQUE constraint in a table definition. "Manually: Users can create nonunique indexes on columns to speed up access to the rows.
  • 16. Creating an Index "Create an index on one or more columns. CREATE INDEXindex ON table (column[, column]...); "Improve the speed of query access to the LAST_NAME column in the EMPLOYEES table. CREATE INDEX emp_last_name_idx ON employees(last_name); Index created.
  • 17. When to Create an Index You should create an index if: " A column contains a wide range of values " A column contains a large number of null values " One or more columns are frequently used together in a WHERE clause or a join condition "The table is large and most queries are expected to retrieve less than 2 to 4 percent of the rows
  • 18. When Not to Create an Index It is usually not worth creating an index if: " The table is small " The columns are not often used as a condition in the query " Most queries are expected to retrieve more than 2 to 4 percent of the rows in the table " The table is updated frequently " The indexed columns are referenced as part of an expression
  • 19. Confirming Indexes "The USER_INDEXES data dictionary view contains the name of the index and its uniqueness. "The USER_IND_COLUMNS view contains the index name, the table name, and the column name. SELECT ic.index_name, ic.column_name, ic.column_position col_pos,ix.uniqueness FRO M user_indexes ix, user_ind_columns ic WHERE ic.index_name = ix.index_name AND ic.table_name = 'EMPLOYEES';
  • 20. Function-Based Indexes "A function-based index is an index based on expressions. "The index expression is built from table columns, constants, SQL functions, and user-defined functions. CREATE INDEX upper_dept_name_idx ON departments(UPPER(department_name)); Index created. SELECT * FROM departments WHERE UPPER(department_name) = 'SALES';
  • 21. Removing an Index "Remove an index from the data dictionary by using the DROP INDEX command. DROP INDEX index; "Remove the UPPER_LAST_NAME_IDX index from the data dictionary. DROP INDEX upper_last_name_idx; Index dropped. "To drop an index, you must be the owner of the index or have the DROP ANY INDEX privilege.
  • 22. Synonyms Simplify access to objects by creating a synonym (another name for an object). With synonyms, you can: " Ease referring to a table owned by another user "Shorten lengthy object names CREATE [PUBLIC] SYNONY M synonym FOR object;
  • 23. Creating and Removing Synonyms "Create a shortened name for the DEPT_SUM_VU view. CREATE SYNONYM d_sum FOR dept_sum_vu; Synonym Created. " Drop a synonym. DROP SYNONYM d_sum; Synonym dropped.