SlideShare a Scribd company logo
1 of 13
Download to read offline
Introduction to Oracle Constraints Concepts
BN1017 A – Demo PPT
Demo Oracle Constraints
http://www.conlinetraining.com/courses/rdbms-online-training/
Oracle Constraints Types
Constraints: -- Constraints apply specific rules to data, ensuring the data conforms to the
requirements defined. There are a number of different kinds of constraints.
There are two ways to apply constraint into Database.
1)Column level Constraint.
2)Table Level Constraint.
http://www.conlinetraining.com/courses/rdbms-online-training/
Types Of Constraints
• Not NULL
• Primary key
• Unique
• Foreign Key
• Check
• Let's look at each of these in a little more detail.
http://www.conlinetraining.com/courses/rdbms-online-training/
Referential Integrity
http://www.conlinetraining.com/courses/rdbms-online-training/
NOT NULL Constraints
NOT NULL constraints are in-line constraints that indicate that a column can not contain NULL
values. For example, the PERSON_ID column is defined as NOT NULL in that example.
If you need to add a NOT NULL constraint to a table after the fact, simply use the alter table co
mmand as in this example:
Syntax:-
create table
customer
(status char(3) not null,
val number not null);
Alter Table Table Name Modify( person_id NOT NULL);
When copying tables with CTAS, beware that NULL values many not copy properly.
http://www.conlinetraining.com/courses/rdbms-online-training/
Primary Key Constraints
Primary key constraints define a column or series of columns that uniquely
identify a given row in a table. Defining a primary key on a table is optional and
you can only define a single primary key on a table. A primary key constraint can
consist of one or many columns (up to 32). Any column that is defined as a
primary key column is automatically set with a NOT NULL status.
Syntax:-create table
customer
(status_id Number CONSTRAINT CONSTRAINT _NAME
);
If you need to primary key constraint to a table after the fact, simply use the alter t
able command.
ALTER TABLE customer ADD CONSTRAINT pk_my_status
PRIMARY KEY (status_id);
http://www.conlinetraining.com/courses/rdbms-online-training/
Unique Constraints
Unique constraints are like alternative primary key constraints.
A unique constraint defines a column, or series of columns, that must be unique in value.
You can have a number of unique constraints defined and the columns can have NULL values
in them, unlike a column that belongs to a primary key constraint.
If you need to add unique key constraints to a table after the fact, simply use the alter table
command.
ALTER TABLE
my_status
ADD CONSTRAINT
uk_my_status
UNIQUE
(status_id,
person_id);
http://www.conlinetraining.com/courses/rdbms-online-training/
Foreign Key Constraints
A foreign key constraint is used to enforce a relationship between two tables. As an example,
take the case of two tables, ITEM and PART. These tables have a relationship (an item can have
none, one or many parts). Foreign key constraints help to enforce that relationship
Well, foreign key constraints help to enforce the types of relationships between tables we have
just demonstrated. In this example we will create the ITEM and PART table. In the process of
doing so, we will create a foreign key relationship between the two:
CREATE TABLE part
( Part_no NUMBER PRIMARY KEY,
Part_desc VARCHAR2(200) NOT NULL );
http://www.conlinetraining.com/courses/rdbms-online-training/
Cont..
CREATE TABLE item (Item_no NUMBER,Part_no NUMBER,Item_desc varchar2(200) NOT
NULL, CONSTRAINT fk_item_part FOREIGN KEY (part_no) REFERENCES PART (part_no),
CONSTRAINT pk_item PRIMARY KEY (item_no, part_no) );
In this example, what we are really interested in is the creation of the ITEM table. First, note
that we defined the primary key as an out of line primary key. This is because it is a composite
primary key and composite primary keys have to be defined out of line.
Now, we are interested in the foreign key definition. You must define foreign key constraints as
out of line constraints, as we have done in our example. Here is a snippet of the command that
we used:
CONSTRAINT fk_item_part FOREIGN KEY (part_no) REFERENCES part (part_no);
http://www.conlinetraining.com/courses/rdbms-online-training/
Constraints
If you need to add foreign key constraints to a table after the fact, simply use the alter table
command as seen here:
ALTER TABLE my_status ADD CONSTRAINT fk_my_status
FOREIGN KEY (part_no) REFERENCES part (part_no);
http://www.conlinetraining.com/courses/rdbms-online-training/
Check Constraints
Check constraints validate that values in a given column meet a specific criteria.
For example, you could create a check constraint on a varchar2 column so it
only can contain the values T or F as in this example:
Create table my_status
( status_id NUMBER PRIMARY KEY,
person_id NUMBER NOT NULL,
active_record VARCHAR2(1) NOT NULL
CHECK (UPPER(active_record)='T' or
UPPER(active_record)='F'),
person_ssn VARCHAR2(20) CONSTRAINT un_person_ssn UNIQUE
);
http://www.conlinetraining.com/courses/rdbms-online-training/
Questions ???
http://www.conlinetraining.com/courses/rdbms-online-training/
Email us : info@conlineTraining.com
Visit : www.conlinetraining.com

More Related Content

Viewers also liked (11)

An_Introduction_to_Excel
An_Introduction_to_ExcelAn_Introduction_to_Excel
An_Introduction_to_Excel
 
Phi Theta Kappa
Phi Theta KappaPhi Theta Kappa
Phi Theta Kappa
 
Commercial Real Estate Trends in the UK
Commercial Real Estate Trends in the UKCommercial Real Estate Trends in the UK
Commercial Real Estate Trends in the UK
 
VINEET_ANAND_CV_HADOOP_VA_V3
VINEET_ANAND_CV_HADOOP_VA_V3VINEET_ANAND_CV_HADOOP_VA_V3
VINEET_ANAND_CV_HADOOP_VA_V3
 
RECURSOS TECNOLÓGICOS
RECURSOS TECNOLÓGICOS RECURSOS TECNOLÓGICOS
RECURSOS TECNOLÓGICOS
 
Podium
Podium Podium
Podium
 
Anthony C Smith Leadership and Interpersonal Skills
Anthony C Smith Leadership and Interpersonal SkillsAnthony C Smith Leadership and Interpersonal Skills
Anthony C Smith Leadership and Interpersonal Skills
 
Nutrilite Dla urody
Nutrilite Dla urodyNutrilite Dla urody
Nutrilite Dla urody
 
مشروع صناديق الهدايا
مشروع صناديق الهدايامشروع صناديق الهدايا
مشروع صناديق الهدايا
 
Making surgical practice improvement easy
Making surgical practice improvement easyMaking surgical practice improvement easy
Making surgical practice improvement easy
 
Priyanka CV
Priyanka CVPriyanka CV
Priyanka CV
 

Similar to Bn1017 a demo rdbms

Sql integrity constraints
Sql integrity constraintsSql integrity constraints
Sql integrity constraints
Vivek Singh
 
2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used
TheVerse1
 
Database constraints
Database constraintsDatabase constraints
Database constraints
Fraboni Ec
 
Database constraints
Database constraintsDatabase constraints
Database constraints
David Hoen
 
Database constraints
Database constraintsDatabase constraints
Database constraints
Tony Nguyen
 
Database constraints
Database constraintsDatabase constraints
Database constraints
James Wong
 
Database constraints
Database constraintsDatabase constraints
Database constraints
Young Alista
 
Sql ch 12 - creating database
Sql ch 12 - creating databaseSql ch 12 - creating database
Sql ch 12 - creating database
Mukesh Tekwani
 

Similar to Bn1017 a demo rdbms (20)

Sql integrity constraints
Sql integrity constraintsSql integrity constraints
Sql integrity constraints
 
Dms 22319 micro project
Dms 22319 micro projectDms 22319 micro project
Dms 22319 micro project
 
1.Implementing_Data_Integrity.pdf
1.Implementing_Data_Integrity.pdf1.Implementing_Data_Integrity.pdf
1.Implementing_Data_Integrity.pdf
 
Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developer
 
Constraints constraints of oracle data base management systems
Constraints  constraints of oracle data base management systemsConstraints  constraints of oracle data base management systems
Constraints constraints of oracle data base management systems
 
Data integrity
Data integrityData integrity
Data integrity
 
RDBMS Lab03 applying constraints (UIU)
RDBMS Lab03 applying constraints (UIU)RDBMS Lab03 applying constraints (UIU)
RDBMS Lab03 applying constraints (UIU)
 
2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used
 
SQL
SQLSQL
SQL
 
Integrity and security
Integrity and securityIntegrity and security
Integrity and security
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Entigrity constraint
Entigrity constraintEntigrity constraint
Entigrity constraint
 
Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013
 
Sql ch 12 - creating database
Sql ch 12 - creating databaseSql ch 12 - creating database
Sql ch 12 - creating database
 

More from conline training

More from conline training (20)

Bn 1024 demo ccnp
Bn 1024 demo  ccnpBn 1024 demo  ccnp
Bn 1024 demo ccnp
 
Bn 1023 demo network security
Bn 1023 demo  network securityBn 1023 demo  network security
Bn 1023 demo network security
 
Bn 1023 demo ccna
Bn 1023 demo  ccnaBn 1023 demo  ccna
Bn 1023 demo ccna
 
Bn 1022 demo mcse 2012
Bn 1022 demo  mcse 2012Bn 1022 demo  mcse 2012
Bn 1022 demo mcse 2012
 
Bn 1021 demo digital marketing
Bn 1021 demo  digital marketingBn 1021 demo  digital marketing
Bn 1021 demo digital marketing
 
Bn 1019 demo sql server 2012
Bn 1019 demo  sql server 2012Bn 1019 demo  sql server 2012
Bn 1019 demo sql server 2012
 
Bn 1018 demo pl sql
Bn 1018 demo  pl sqlBn 1018 demo  pl sql
Bn 1018 demo pl sql
 
Bn 1016 demo postgre sql-online-training
Bn 1016 demo  postgre sql-online-trainingBn 1016 demo  postgre sql-online-training
Bn 1016 demo postgre sql-online-training
 
B10014 ppt for msbi
B10014 ppt for msbiB10014 ppt for msbi
B10014 ppt for msbi
 
B1015 demo on selenium testing tools
B1015 demo on selenium testing toolsB1015 demo on selenium testing tools
B1015 demo on selenium testing tools
 
Bn1038 demo pega
Bn1038 demo  pegaBn1038 demo  pega
Bn1038 demo pega
 
Bn1033 demo sap basis
Bn1033 demo  sap basisBn1033 demo  sap basis
Bn1033 demo sap basis
 
Bn1032 demo sap bo
Bn1032 demo  sap boBn1032 demo  sap bo
Bn1032 demo sap bo
 
Bn1031 demo sap ehs
Bn1031 demo sap ehsBn1031 demo sap ehs
Bn1031 demo sap ehs
 
Bn1030 oracle dba
Bn1030 oracle dbaBn1030 oracle dba
Bn1030 oracle dba
 
Bn1029 demo sap sd
Bn1029 demo  sap sdBn1029 demo  sap sd
Bn1029 demo sap sd
 
Bn1028 demo hadoop administration and development
Bn1028 demo  hadoop administration and developmentBn1028 demo  hadoop administration and development
Bn1028 demo hadoop administration and development
 
Bn1025 demo basic unix
Bn1025 demo  basic unixBn1025 demo  basic unix
Bn1025 demo basic unix
 
Bn1013 demo sap success factors
Bn1013 demo  sap success factorsBn1013 demo  sap success factors
Bn1013 demo sap success factors
 
Bn1012 demo ppt sap pm
Bn1012 demo ppt sap pmBn1012 demo ppt sap pm
Bn1012 demo ppt sap pm
 

Recently uploaded

Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
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
QucHHunhnh
 

Recently uploaded (20)

Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
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
 
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
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
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
 

Bn1017 a demo rdbms