SlideShare a Scribd company logo
Anar Godjaev
http://anargodjaev.wordpress.com/

Contraints/Objects/Set Operators
Not null
Unique
Primary key
Foreign key
Check
Create table employees
(
employee_id number(6) ,
First_namevarchar2(20),
Job_idvarchar2(10) not null,
Constraint emp_emp_id_pk primary key (employee_id),
Constraint emp_dep_fk foreign key (department_id) references
Departments (department_id) [on delete]
[cascade | set null] );

Constraint <constraint_name>pimary key (col_names)
Unique (col_names)
Check (condition)
Foreign key (col_name) references
tab_name (col_name)

Alter table table_name add constraint c_nametypce (col);
Constraint emp_Sal_min check (salary > 0);
Alter table employees drop | disable | enable constraint const_name;
Create view v$name as select * from tbl_name;
Create or replace view empv10 as
...
with check option name
read only;

selectrownum as rank , last_name , salary from ... where rownum<= 3;

Objects:
table , view, sequence, index, synonym
sequence:
Anar Godjaev
http://anargodjaev.wordpress.com/

create sequence seq_name
increment by n
start with n
maxvalue n
minvalue n
cycle | no cycle
cache | no cache
seq_name.currval
seq_name.nextval
alter sequence seq_name ...
describeuser_sequences
create index index on table (column)
create index index on table (upper(column));
create public synonym synonym_name for object
create user scott identified by tiger
grantpriviligerouser_name | role
create session
create table
create sequence
create view
create role manager
grantpriv to manager
grant manager to user

alter user scott identified by lion;
grantobject_priv on object to user | role [with grant option]
alter
delete
execute
index
insert
references
select
update
Anar Godjaev
http://anargodjaev.wordpress.com/
Grant update (department_name ,location_id)
on departments to scott, manager

Set operators:
union
union all //includes duplicate rows
intersect
minus
selectdepartment_id, job_id, sum(salary) from employees where department_id<
60
group by rollup | cube (department_id, job_id);
selectdepartment_id , job_idmanager_id, avg(salary) from employees
group by grouping sets ((department_id, job_id) , (job_id, manager_id));
selectdepartment_id , job_id , sum(salary) from employees where department_id<
60
group by [rollup | cube] (department_id, job_id);
group by grouping sets ((, , , ) , (, , ,))
exists , not exists
alter table employees add (department_name varchar2(14));
update employees e set department_name = (select department_name from
departments.d
wheree.department_id = d.department_id);

More Related Content

PPTX
Component lifecycle hooks in Angular 2.0
PDF
Unit testing UIView
PDF
PPT
Common Pitfalls Experienced in Java
PDF
2013 28-03-dak-why-fp
PPTX
Deploying Straight to Production
PDF
Slaying the Dragon: Implementing a Programming Language in Ruby
PDF
龍華大學前端技術分享 Part2
Component lifecycle hooks in Angular 2.0
Unit testing UIView
Common Pitfalls Experienced in Java
2013 28-03-dak-why-fp
Deploying Straight to Production
Slaying the Dragon: Implementing a Programming Language in Ruby
龍華大學前端技術分享 Part2

What's hot (20)

PDF
Unittests für Dummies
PPT
Sencha Touch Intro
PPTX
AngularJS Compile Process
PPTX
Top 5 Magento Secure Coding Best Practices
KEY
Decent exposure: Controladores sin @ivars
DOCX
Array imp of list
PDF
Four Ways to add Features to Ext JS
PDF
Code moi une RH! (PHP tour 2017)
PPTX
Array menu
PPTX
AngularJS $Provide Service
PDF
Practical JavaScript Programming - Session 6/8
PDF
大量地区化解决方案V5
PPT
Ext oo
PPTX
Metaprogramming in ES6
PPT
Aggregate functions
PPTX
Django tips and_tricks (1)
PDF
Standford 2015 week3: Objective-C Compatibility, Property List, Views
PDF
Parametrized testing, v2
PDF
Simulator customizing & testing for Xcode 9
PDF
PHPUnit でよりよくテストを書くために
Unittests für Dummies
Sencha Touch Intro
AngularJS Compile Process
Top 5 Magento Secure Coding Best Practices
Decent exposure: Controladores sin @ivars
Array imp of list
Four Ways to add Features to Ext JS
Code moi une RH! (PHP tour 2017)
Array menu
AngularJS $Provide Service
Practical JavaScript Programming - Session 6/8
大量地区化解决方案V5
Ext oo
Metaprogramming in ES6
Aggregate functions
Django tips and_tricks (1)
Standford 2015 week3: Objective-C Compatibility, Property List, Views
Parametrized testing, v2
Simulator customizing & testing for Xcode 9
PHPUnit でよりよくテストを書くために
Ad

Viewers also liked (7)

PPT
ABAP Material 04
PPTX
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
PPT
Chapter 03 foreign key relationships1
PPTX
SQL for ETL Testing
PPTX
Importance of data model
PPT
Database constraints
PPT
Entity relationship diagram (erd)
ABAP Material 04
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Chapter 03 foreign key relationships1
SQL for ETL Testing
Importance of data model
Database constraints
Entity relationship diagram (erd)
Ad

Similar to Contraints (20)

PPT
e computer notes - Including constraints
PPT
Less08 Schema
PPT
PPTX
Database Project of a Corporation or Firm
DOCX
RELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docx
PDF
Here is the company database for the problem--commen.pdf
PDF
Here is the company database--comments can be addedD.pdf
DOC
Activity sep11 solution
PPT
PPT
PPT
SQL WORKSHOP::Lecture 11
PPT
Creating other schema objects
PPT
PDF
1.Implementing_Data_Integrity.pdf
PDF
Constraint Optimization
PDF
Oracle (SQL), Sulieman Khudruj
PPTX
zekeLabs sql-slides
PPT
Module 3 _SQL Database Management System
e computer notes - Including constraints
Less08 Schema
Database Project of a Corporation or Firm
RELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docx
Here is the company database for the problem--commen.pdf
Here is the company database--comments can be addedD.pdf
Activity sep11 solution
SQL WORKSHOP::Lecture 11
Creating other schema objects
1.Implementing_Data_Integrity.pdf
Constraint Optimization
Oracle (SQL), Sulieman Khudruj
zekeLabs sql-slides
Module 3 _SQL Database Management System

More from Anar Godjaev (20)

DOCX
Oracle GoldenGate
DOCX
Asm disk group migration from
DOCX
How to protect your sensitive data using oracle database vault / Creating and...
DOCX
how to protect your sensitive data using oracle database vault
DOCX
Database Vault / Verinin Güvenliği
DOCX
Oracle Golden Gate
PDF
Oracle 10g Database Server Kurulum
DOCX
DataPump ile Single Parititon Export
DOCX
Redologlar ve Yöneti̇mi̇
DOCX
Oracle SQL
DOCX
Veri̇tabani ve Kullanici Yöneti̇mi̇
DOCX
Instance ve Media Bozukluklarını Inceleme
DOCX
Conditional Control
DOCX
PL/SQL Blocks
DOCX
Wait Interface
DOCX
Audit Mekani̇zmasi
DOCX
Tuning SGA
DOCX
Parallel Server
DOCX
Table Partitions
DOCX
Backup and Recovery
Oracle GoldenGate
Asm disk group migration from
How to protect your sensitive data using oracle database vault / Creating and...
how to protect your sensitive data using oracle database vault
Database Vault / Verinin Güvenliği
Oracle Golden Gate
Oracle 10g Database Server Kurulum
DataPump ile Single Parititon Export
Redologlar ve Yöneti̇mi̇
Oracle SQL
Veri̇tabani ve Kullanici Yöneti̇mi̇
Instance ve Media Bozukluklarını Inceleme
Conditional Control
PL/SQL Blocks
Wait Interface
Audit Mekani̇zmasi
Tuning SGA
Parallel Server
Table Partitions
Backup and Recovery

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Approach and Philosophy of On baking technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mushroom cultivation and it's methods.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
1. Introduction to Computer Programming.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Machine learning based COVID-19 study performance prediction
Approach and Philosophy of On baking technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Getting Started with Data Integration: FME Form 101
NewMind AI Weekly Chronicles - August'25-Week II
OMC Textile Division Presentation 2021.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Diabetes mellitus diagnosis method based random forest with bat algorithm
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Network Security Unit 5.pdf for BCA BBA.
Mushroom cultivation and it's methods.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
Univ-Connecticut-ChatGPT-Presentaion.pdf
Heart disease approach using modified random forest and particle swarm optimi...
1. Introduction to Computer Programming.pptx
Spectral efficient network and resource selection model in 5G networks
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

Contraints

  • 1. Anar Godjaev http://anargodjaev.wordpress.com/ Contraints/Objects/Set Operators Not null Unique Primary key Foreign key Check Create table employees ( employee_id number(6) , First_namevarchar2(20), Job_idvarchar2(10) not null, Constraint emp_emp_id_pk primary key (employee_id), Constraint emp_dep_fk foreign key (department_id) references Departments (department_id) [on delete] [cascade | set null] ); Constraint <constraint_name>pimary key (col_names) Unique (col_names) Check (condition) Foreign key (col_name) references tab_name (col_name) Alter table table_name add constraint c_nametypce (col); Constraint emp_Sal_min check (salary > 0); Alter table employees drop | disable | enable constraint const_name; Create view v$name as select * from tbl_name; Create or replace view empv10 as ... with check option name read only; selectrownum as rank , last_name , salary from ... where rownum<= 3; Objects: table , view, sequence, index, synonym sequence:
  • 2. Anar Godjaev http://anargodjaev.wordpress.com/ create sequence seq_name increment by n start with n maxvalue n minvalue n cycle | no cycle cache | no cache seq_name.currval seq_name.nextval alter sequence seq_name ... describeuser_sequences create index index on table (column) create index index on table (upper(column)); create public synonym synonym_name for object create user scott identified by tiger grantpriviligerouser_name | role create session create table create sequence create view create role manager grantpriv to manager grant manager to user alter user scott identified by lion; grantobject_priv on object to user | role [with grant option] alter delete execute index insert references select update
  • 3. Anar Godjaev http://anargodjaev.wordpress.com/ Grant update (department_name ,location_id) on departments to scott, manager Set operators: union union all //includes duplicate rows intersect minus selectdepartment_id, job_id, sum(salary) from employees where department_id< 60 group by rollup | cube (department_id, job_id); selectdepartment_id , job_idmanager_id, avg(salary) from employees group by grouping sets ((department_id, job_id) , (job_id, manager_id)); selectdepartment_id , job_id , sum(salary) from employees where department_id< 60 group by [rollup | cube] (department_id, job_id); group by grouping sets ((, , , ) , (, , ,)) exists , not exists alter table employees add (department_name varchar2(14)); update employees e set department_name = (select department_name from departments.d wheree.department_id = d.department_id);