SlideShare ist ein Scribd-Unternehmen logo
1 von 27
7-1 Copyright © 2005, Oracle. All rights reserved.
Managing Schema Objects
7-2 Copyright © 2005, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to do
the following:
• Define schema objects and data types
• Create and modify tables
• Define constraints
• User
• User accounts
• Create indexes
• Naming Schema Object
• Object Namespaces
• Explain the use of temporary tables
7-3 Copyright © 2005, Oracle. All rights reserved.
Database Schema
 A database schema defines how data is organized
within a relational database.
 This is inclusive of logical constraints such as, table
names, fields, data types, and the relationships between
these entities.
7-4 Copyright © 2005, Oracle. All rights reserved.
What Is a Schema?
HR schema
HR user
owns
> Schema
Constraints
Indexes
Views
Temp Tables
7-5 Copyright © 2005, Oracle. All rights reserved.
Schema Objects
7-6 Copyright © 2005, Oracle. All rights reserved.
Naming Database Objects
• The length of names must be from 1 to 30 bytes,
with these exceptions:
– Names of databases are limited to 8 bytes.
– Names of database links can be as long as
128 bytes.
• Nonquoted names cannot be Oracle-reserved
words.
• Nonquoted names must begin with an alphabetic
character from your database character set.
• Quoted names are not recommended.
7-7 Copyright © 2005, Oracle. All rights reserved.
Object Namespaces
 A Namespace is a container for a set of
identifiers(symbols or names).
 A namespace defines a group of object types, within
which all names must be uniquely identified, by schema
and name. Objects in different namespaces can share
the same name.
These object types all share the same namespace:
 Tables
 Views
 Sequences
 Private synonyms
7-8 Copyright © 2005, Oracle. All rights reserved.
Data Types in Tables
Common data types:
• CHAR(size [BYTE|CHAR]): Fixed-length character
data of size bytes or characters
• VARCHAR2(size [BYTE|CHAR]): Variable-length
character string having a maximum length of size
bytes or characters
• DATE: Valid date ranging from January 1, 4712 B.C.
through A.D. December 31, 9999
• NUMBER(p,s): Number with precision p and
scale s
7-9 Copyright © 2005, Oracle. All rights reserved.
Creating and Modifying Tables
Specify the table
name and schema.
Specify the column names,
data types, and lengths.
7-10 Copyright © 2005, Oracle. All rights reserved.
DBA User
 A database administrator is a database user of the
database user class DBA.
 Database administrators can manage database users
and database objects.
 The database system administrator is a special
database user of database user class SYSDBA
(administrator).
7-11 Copyright © 2005, Oracle. All rights reserved.
User Accounts
 For users to access your database, you must create
user accounts and grant appropriate database access
privileges to those accounts.
 A user account is identified by a user name and defines
the attributes of the user, including the following:
 Authentication method
 Password for database authentication
 Default tablespaces for permanent and temporary data
storage
 Tablespace quotas
 Account status (locked or unlocked)
 Password status (expired or not)
7-12 Copyright © 2005, Oracle. All rights reserved.
Defining Constraints
7-13 Copyright © 2005, Oracle. All rights reserved.
Constraint Violations
Examples of how a constraint can be violated are:
• Inserting a duplicate primary key value
• Deleting the parent of a child row in a referential
integrity constraint
• Updating a column to a value that is out of the bounds
of a check constraint
101 …
102 …
103 …
101
X … 22
… 49
… 16
… 5
ID AGE
–30
7-14 Copyright © 2005, Oracle. All rights reserved.
Constraint States
ENABLE
NOVALIDATE
ENABLE
VALIDATE
Existing data
New data
DISABLE
NOVALIDATE
DISABLE
VALIDATE
No DML
7-15 Copyright © 2005, Oracle. All rights reserved.
Constraint Checking
Case: DML statement, followed by COMMIT
Nondeferred constraints
checked
COMMIT issued
Deferred constraints checked
COMMIT complete
1
3
2
4
Constraints are checked at the time of:
• Statement execution, for nondeferred constraints
• COMMIT, for deferred constraints
7-16 Copyright © 2005, Oracle. All rights reserved.
Creating Constraints with SQL: Examples
ALTER TABLE countries
ADD (UNIQUE(country_name) ENABLE NOVALIDATE);
ALTER TABLE employees ADD CONSTRAINT pk PRIMARY KEY
(employee_id)
CREATE TABLE t1 (pk NUMBER PRIMARY KEY, fk NUMBER, c1 NUMBER,
c2 NUMBER,
CONSTRAINT ri FOREIGN KEY (fk) REFERENCES t1,CONSTRAINT ck1
CHECK (pk > 0 and c1 > 0));
a
c
b
7-17 Copyright © 2005, Oracle. All rights reserved.
Viewing the Columns in a Table
7-18 Copyright © 2005, Oracle. All rights reserved.
Viewing the Contents of a Table
7-19 Copyright © 2005, Oracle. All rights reserved.
Indexes
22
22
Index Table
Key
Row
pointer
… WHERE key = 22
Schema
Constraints
> Indexes
Views
Temp Tables
7-20 Copyright © 2005, Oracle. All rights reserved.
Types of Indexes
These are several types of index structures available
to you, depending on the need:
• A B-tree index is in the form of a binary tree and is the
default index type.
• A bitmap index has a bitmap for each distinct value
indexed, and each bit position represents a row that
may or may not contain the indexed value. This is best
for low-cardinality columns.
7-21 Copyright © 2005, Oracle. All rights reserved.
B-Tree Index
Index entry header
Key column length
Key column value
ROWID
Root
Branch
Leaf
Index entry
7-22 Copyright © 2005, Oracle. All rights reserved.
Bitmap Indexes
<Blue, 10.0.3, 12.8.3, 1000100100010010100>
<Green, 10.0.3, 12.8.3, 0001010000100100000>
<Red, 10.0.3, 12.8.3, 0100000011000001001>
<Yellow, 10.0.3, 12.8.3, 0010001000001000010>
Key
Start
ROWID
End
ROWID Bitmap
Table
Index
Block 10
Block 11
Block 12
File 3
7-23 Copyright © 2005, Oracle. All rights reserved.
Index Options
• A unique index ensures that every indexed value is
unique.
• An index can have its key values stored in ascending
or descending order.
• A reverse key index has its key value bytes stored in
reverse order.
• A composite index is one that is based on more than
one column.
• A function-based index is an index based on a
function’s return value.
• A compressed index has repeated key values
removed.
7-24 Copyright © 2005, Oracle. All rights reserved.
Creating Indexes
CREATE INDEX my_index ON
employees(last_name, first_name);
7-25 Copyright © 2005, Oracle. All rights reserved.
Temporary Tables
A temporary table:
• Provides storage of data that is automatically cleaned
up when the session or transaction ends
• Provides private storage of data for each session
• Is available to all sessions for use without affecting
each other’s private data
Schema
Constraints
Indexes
Temp Tables
7-26 Copyright © 2005, Oracle. All rights reserved.
Temporary Tables: Considerations
• Use the GLOBAL TEMPORARY clause to create
temporary tables:
• Use the TRUNCATE TABLE command to delete the
contents of the table.
• You can create the following on temporary tables:
– Indexes
– Views
– Triggers
CREATE GLOBAL TEMPORARY TABLE employees_temp
ON COMMIT PRESERVE ROWS
AS SELECT * FROM employees;
7-27 Copyright © 2005, Oracle. All rights reserved.
Thank You

Weitere ähnliche Inhalte

Was ist angesagt?

All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbmsNaresh Kumar
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship ModelSlideshare
 
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaPostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaEdureka!
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning Arno Huetter
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLMSB Academy
 
OOAD unit1 introduction to object orientation
 OOAD unit1 introduction to object orientation OOAD unit1 introduction to object orientation
OOAD unit1 introduction to object orientationDr Chetan Shelke
 
Oracle RAC, Oracle Data Guard, and Pluggable Databases: When MAA Meets Oracle...
Oracle RAC, Oracle Data Guard, and Pluggable Databases: When MAA Meets Oracle...Oracle RAC, Oracle Data Guard, and Pluggable Databases: When MAA Meets Oracle...
Oracle RAC, Oracle Data Guard, and Pluggable Databases: When MAA Meets Oracle...Ludovico Caldara
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship ModelNeil Neelesh
 
data modeling and models
data modeling and modelsdata modeling and models
data modeling and modelssabah N
 
11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilarrehaniltifat
 
Oracle architecture ppt
Oracle architecture pptOracle architecture ppt
Oracle architecture pptDeepak Shetty
 
An Introduction To Oracle Database
An Introduction To Oracle DatabaseAn Introduction To Oracle Database
An Introduction To Oracle DatabaseMeysam Javadi
 

Was ist angesagt? (20)

All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbms
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
SQL subquery
SQL subquerySQL subquery
SQL subquery
 
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaPostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | Edureka
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQL
 
Entity relationship modelling
Entity relationship modellingEntity relationship modelling
Entity relationship modelling
 
User defined Function in SQL
User defined Function in SQLUser defined Function in SQL
User defined Function in SQL
 
OOAD unit1 introduction to object orientation
 OOAD unit1 introduction to object orientation OOAD unit1 introduction to object orientation
OOAD unit1 introduction to object orientation
 
Oracle RAC, Oracle Data Guard, and Pluggable Databases: When MAA Meets Oracle...
Oracle RAC, Oracle Data Guard, and Pluggable Databases: When MAA Meets Oracle...Oracle RAC, Oracle Data Guard, and Pluggable Databases: When MAA Meets Oracle...
Oracle RAC, Oracle Data Guard, and Pluggable Databases: When MAA Meets Oracle...
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
data modeling and models
data modeling and modelsdata modeling and models
data modeling and models
 
Data partitioning
Data partitioningData partitioning
Data partitioning
 
11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar
 
Oracle database introduction
Oracle database introductionOracle database introduction
Oracle database introduction
 
Data cubes
Data cubesData cubes
Data cubes
 
Oracle architecture ppt
Oracle architecture pptOracle architecture ppt
Oracle architecture ppt
 
An Introduction To Oracle Database
An Introduction To Oracle DatabaseAn Introduction To Oracle Database
An Introduction To Oracle Database
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 

Ähnlich wie Manage schema object.ppt

Ähnlich wie Manage schema object.ppt (20)

Less07 schema
Less07 schemaLess07 schema
Less07 schema
 
Less08_Schema Advanced Databases and Management.pptx
Less08_Schema Advanced Databases and Management.pptxLess08_Schema Advanced Databases and Management.pptx
Less08_Schema Advanced Databases and Management.pptx
 
Creating and Managing Tables -Oracle Data base
Creating and Managing Tables -Oracle Data base Creating and Managing Tables -Oracle Data base
Creating and Managing Tables -Oracle Data base
 
Les09.ppt
Les09.pptLes09.ppt
Les09.ppt
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
 
plsql Les09
 plsql Les09 plsql Les09
plsql Les09
 
Dbms oracle
Dbms oracle Dbms oracle
Dbms oracle
 
Lesson09
Lesson09Lesson09
Lesson09
 
Les10.ppt
Les10.pptLes10.ppt
Les10.ppt
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Les09
Les09Les09
Les09
 
Intro
IntroIntro
Intro
 
Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
 
unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
 
sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql commands
Sql commandsSql commands
Sql commands
 
Cursores.ppt
Cursores.pptCursores.ppt
Cursores.ppt
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
 

Mehr von AhmadUsman79

Humair (project management).pdf
Humair (project management).pdfHumair (project management).pdf
Humair (project management).pdfAhmadUsman79
 
1588425445-2-human.ppt
1588425445-2-human.ppt1588425445-2-human.ppt
1588425445-2-human.pptAhmadUsman79
 
1588424325-1-introduction-to-hci.ppt
1588424325-1-introduction-to-hci.ppt1588424325-1-introduction-to-hci.ppt
1588424325-1-introduction-to-hci.pptAhmadUsman79
 
issues in change management.pptx
issues in change management.pptxissues in change management.pptx
issues in change management.pptxAhmadUsman79
 
Security management.pptx
Security management.pptxSecurity management.pptx
Security management.pptxAhmadUsman79
 
compelte%20slides.pptx
compelte%20slides.pptxcompelte%20slides.pptx
compelte%20slides.pptxAhmadUsman79
 

Mehr von AhmadUsman79 (7)

Humair (project management).pdf
Humair (project management).pdfHumair (project management).pdf
Humair (project management).pdf
 
1588425445-2-human.ppt
1588425445-2-human.ppt1588425445-2-human.ppt
1588425445-2-human.ppt
 
1588424325-1-introduction-to-hci.ppt
1588424325-1-introduction-to-hci.ppt1588424325-1-introduction-to-hci.ppt
1588424325-1-introduction-to-hci.ppt
 
School.pptx
School.pptxSchool.pptx
School.pptx
 
issues in change management.pptx
issues in change management.pptxissues in change management.pptx
issues in change management.pptx
 
Security management.pptx
Security management.pptxSecurity management.pptx
Security management.pptx
 
compelte%20slides.pptx
compelte%20slides.pptxcompelte%20slides.pptx
compelte%20slides.pptx
 

Kürzlich hochgeladen

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.MaryamAhmad92
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
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 POSCeline George
 
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.christianmathematics
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
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...pradhanghanshyam7136
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Kürzlich hochgeladen (20)

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.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
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
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
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.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
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...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

Manage schema object.ppt

  • 1. 7-1 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects
  • 2. 7-2 Copyright © 2005, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: • Define schema objects and data types • Create and modify tables • Define constraints • User • User accounts • Create indexes • Naming Schema Object • Object Namespaces • Explain the use of temporary tables
  • 3. 7-3 Copyright © 2005, Oracle. All rights reserved. Database Schema  A database schema defines how data is organized within a relational database.  This is inclusive of logical constraints such as, table names, fields, data types, and the relationships between these entities.
  • 4. 7-4 Copyright © 2005, Oracle. All rights reserved. What Is a Schema? HR schema HR user owns > Schema Constraints Indexes Views Temp Tables
  • 5. 7-5 Copyright © 2005, Oracle. All rights reserved. Schema Objects
  • 6. 7-6 Copyright © 2005, Oracle. All rights reserved. Naming Database Objects • The length of names must be from 1 to 30 bytes, with these exceptions: – Names of databases are limited to 8 bytes. – Names of database links can be as long as 128 bytes. • Nonquoted names cannot be Oracle-reserved words. • Nonquoted names must begin with an alphabetic character from your database character set. • Quoted names are not recommended.
  • 7. 7-7 Copyright © 2005, Oracle. All rights reserved. Object Namespaces  A Namespace is a container for a set of identifiers(symbols or names).  A namespace defines a group of object types, within which all names must be uniquely identified, by schema and name. Objects in different namespaces can share the same name. These object types all share the same namespace:  Tables  Views  Sequences  Private synonyms
  • 8. 7-8 Copyright © 2005, Oracle. All rights reserved. Data Types in Tables Common data types: • CHAR(size [BYTE|CHAR]): Fixed-length character data of size bytes or characters • VARCHAR2(size [BYTE|CHAR]): Variable-length character string having a maximum length of size bytes or characters • DATE: Valid date ranging from January 1, 4712 B.C. through A.D. December 31, 9999 • NUMBER(p,s): Number with precision p and scale s
  • 9. 7-9 Copyright © 2005, Oracle. All rights reserved. Creating and Modifying Tables Specify the table name and schema. Specify the column names, data types, and lengths.
  • 10. 7-10 Copyright © 2005, Oracle. All rights reserved. DBA User  A database administrator is a database user of the database user class DBA.  Database administrators can manage database users and database objects.  The database system administrator is a special database user of database user class SYSDBA (administrator).
  • 11. 7-11 Copyright © 2005, Oracle. All rights reserved. User Accounts  For users to access your database, you must create user accounts and grant appropriate database access privileges to those accounts.  A user account is identified by a user name and defines the attributes of the user, including the following:  Authentication method  Password for database authentication  Default tablespaces for permanent and temporary data storage  Tablespace quotas  Account status (locked or unlocked)  Password status (expired or not)
  • 12. 7-12 Copyright © 2005, Oracle. All rights reserved. Defining Constraints
  • 13. 7-13 Copyright © 2005, Oracle. All rights reserved. Constraint Violations Examples of how a constraint can be violated are: • Inserting a duplicate primary key value • Deleting the parent of a child row in a referential integrity constraint • Updating a column to a value that is out of the bounds of a check constraint 101 … 102 … 103 … 101 X … 22 … 49 … 16 … 5 ID AGE –30
  • 14. 7-14 Copyright © 2005, Oracle. All rights reserved. Constraint States ENABLE NOVALIDATE ENABLE VALIDATE Existing data New data DISABLE NOVALIDATE DISABLE VALIDATE No DML
  • 15. 7-15 Copyright © 2005, Oracle. All rights reserved. Constraint Checking Case: DML statement, followed by COMMIT Nondeferred constraints checked COMMIT issued Deferred constraints checked COMMIT complete 1 3 2 4 Constraints are checked at the time of: • Statement execution, for nondeferred constraints • COMMIT, for deferred constraints
  • 16. 7-16 Copyright © 2005, Oracle. All rights reserved. Creating Constraints with SQL: Examples ALTER TABLE countries ADD (UNIQUE(country_name) ENABLE NOVALIDATE); ALTER TABLE employees ADD CONSTRAINT pk PRIMARY KEY (employee_id) CREATE TABLE t1 (pk NUMBER PRIMARY KEY, fk NUMBER, c1 NUMBER, c2 NUMBER, CONSTRAINT ri FOREIGN KEY (fk) REFERENCES t1,CONSTRAINT ck1 CHECK (pk > 0 and c1 > 0)); a c b
  • 17. 7-17 Copyright © 2005, Oracle. All rights reserved. Viewing the Columns in a Table
  • 18. 7-18 Copyright © 2005, Oracle. All rights reserved. Viewing the Contents of a Table
  • 19. 7-19 Copyright © 2005, Oracle. All rights reserved. Indexes 22 22 Index Table Key Row pointer … WHERE key = 22 Schema Constraints > Indexes Views Temp Tables
  • 20. 7-20 Copyright © 2005, Oracle. All rights reserved. Types of Indexes These are several types of index structures available to you, depending on the need: • A B-tree index is in the form of a binary tree and is the default index type. • A bitmap index has a bitmap for each distinct value indexed, and each bit position represents a row that may or may not contain the indexed value. This is best for low-cardinality columns.
  • 21. 7-21 Copyright © 2005, Oracle. All rights reserved. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry
  • 22. 7-22 Copyright © 2005, Oracle. All rights reserved. Bitmap Indexes <Blue, 10.0.3, 12.8.3, 1000100100010010100> <Green, 10.0.3, 12.8.3, 0001010000100100000> <Red, 10.0.3, 12.8.3, 0100000011000001001> <Yellow, 10.0.3, 12.8.3, 0010001000001000010> Key Start ROWID End ROWID Bitmap Table Index Block 10 Block 11 Block 12 File 3
  • 23. 7-23 Copyright © 2005, Oracle. All rights reserved. Index Options • A unique index ensures that every indexed value is unique. • An index can have its key values stored in ascending or descending order. • A reverse key index has its key value bytes stored in reverse order. • A composite index is one that is based on more than one column. • A function-based index is an index based on a function’s return value. • A compressed index has repeated key values removed.
  • 24. 7-24 Copyright © 2005, Oracle. All rights reserved. Creating Indexes CREATE INDEX my_index ON employees(last_name, first_name);
  • 25. 7-25 Copyright © 2005, Oracle. All rights reserved. Temporary Tables A temporary table: • Provides storage of data that is automatically cleaned up when the session or transaction ends • Provides private storage of data for each session • Is available to all sessions for use without affecting each other’s private data Schema Constraints Indexes Temp Tables
  • 26. 7-26 Copyright © 2005, Oracle. All rights reserved. Temporary Tables: Considerations • Use the GLOBAL TEMPORARY clause to create temporary tables: • Use the TRUNCATE TABLE command to delete the contents of the table. • You can create the following on temporary tables: – Indexes – Views – Triggers CREATE GLOBAL TEMPORARY TABLE employees_temp ON COMMIT PRESERVE ROWS AS SELECT * FROM employees;
  • 27. 7-27 Copyright © 2005, Oracle. All rights reserved. Thank You