SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Oracle SQL Developer
Essentials
TABLES AND INDEXES
BASIC CREATE TABLE SYNTAX
CREATE TABLE courses
(
department_code VARCHAR2(2) NOT NULL,
course_number NUMBER(3,0) NOT NULL,
course_title VARCHAR2(64) NOT NULL,
course_description VARCHAR2(512) NOT NULL,
credits NUMBER(3,1) NOT NULL,
CONSTRAINT pk_coursesPRIMARY KEY (department_code, course_number),
CONSTRAINT fk_courses_department_code FOREIGN KEY
(department_code) REFERENCES departments (department_code)
CONSTRAINT ck_courses_course_number CHECK (course_numberBETWEEN 100 AND 999)
)
TABLESPACE users
PCTFREE 75;
• Column Naming rules
1. 30 characters maximum
2. Names must be unique withing a table
3. Names can be reused in other table
• Number of columns per table
1. Maximum of 1000 columns
2. Over 255 columns result in row chaining
Column Definition Rules
• Minimum Information
1. Names and datatypes must be specified
2. Null and default clauses are optional
CREATE TABLE students
(
student_id NUMBER(6) NOT NULL,
first_name VARCHAR2(30) NOT NULL,
last_name VARCHAR2(30) NOT NULL,
email_address VARCHAR2(128) NOT NULL,
phone VARCHAR2(20) NULL,
city VARCHAR2(30),
state VARCHAR2(2) ,
status_code VARCHAR2(1) DEFAULT ‘A’ NOT NULL,
CONSTRAINT pk_studentsPRIMARY KEY (student_id)
);
Null column values
If not specified , default it will accept null values
CREATE TABLE orders
(
order_id NUMBER(10) NOT NULL,
order_date DATE NOT NULL,
customer_id NUMBER(10) NOT NULL,
subtotal NUMBER(10,2),
tax NUMBER(10,2),
shipping NUMBER(10,2),
grand_total NUMBER(10,2)
AS (subtotal + tax + shipping) VIRTUAL
);
Virtual Column
• Virtual columns are not stored in physical disk space
• You cannot perform insert or update operation on virtual column
• Value is computed in the result set of the query
• Cannot insert or update virtual columns
• Can only make use of columns in the same
table
• Index can be created over virtual column
values
CREATE TABLE students
(
student_id NUMBER(6) NOT NULL,
first_name VARCHAR2(30) NOT NULL,
last_name VARCHAR2(30) NOT NULL,
email_address VARCHAR2(128) NOT
NULL,
phone VARCHAR2(20) NULL,
city VARCHAR2(30) NULL,
state VARCHAR2(2) NULL,
CONSTRAINT pk_students PRIMARY
KEY (student_id)
);
Primary Key
• Primary Key Types
1. Natural Key
- Combination of naturally occurring
columns that forms a unique key
2. Surrogate Key
- A unique value is generated for each
row
• Uniquely Identifies each rows in a column
• Can be defined over one or more column
• Cannot contain a null value in primary key
column
CREATE TABLE courses
(
department_code VARCHAR2(2) NOT
NULL,
course_number NUMBER(3,0) NOT NULL,
course_title VARCHAR2(64) NOT NULL,
course_description VARCHAR2(512) NOT
NULL,
credits NUMBER(3,1) NOT NULL,
CONSTRAINT pk_courses
PRIMARY KEY (department_code,
course_number)
);
Primary Key Using constraint clause
Adding Primary Key to an Existing table
ALTER TABLE courses
CONSTRAINT pk_courses
ADD PRIMARY KEY (department_code,
course_number);
SQL> SELECT rowid, zip_code, city, state
2 FROM zip_codes;
ROWID ZIP_C CITY ST
----------------------- --------------------------------
AAAXoNAAGAAAJzeAAA11201 Brooklyn NY
AAAXoNAAGAAAJzeAAB75201 Dallas TX
AAAXoNAAGAAAJzeAAC80401 Golden CO
AAAXoNAAGAAAJzeAAD92101 San Diego CA
Oracle ROWID
It is not intended to use ROWID as a
replacement for primary key.
Foreign Key
Foreign Key Continues…
CREATE TABLE courses
(
department_code VARCHAR2(2) NOT NULL,
course_number NUMBER(3,0) NOT NULL,
course_title VARCHAR2(64) NOT NULL,
course_description VARCHAR2(512) NOT NULL,
credits NUMBER(3,1) NOT NULL,
CONSTRAINT pk_courses
PRIMARY KEY (department_code,
course_number),
C O N S T R A I N T
f k _ c o u r s e s _ d e p a r t m e n t _ c o d e
F O R E I G N K E Y (d e p a r t m e n t _ c o d e )
R E F E R E N C E S d e p a r t m e n t s
(d e p a r t m e n t _ c o d e ) ,
);
Add a Foreign Key to an Existing Table
ALTER TABLE courses
CONSTRAINT fk_courses_department_code
ADD FOREIGN KEY (department_code)
REFERENCES departments
(department_code);
On Delete Cascade
CREATE TABLE courses
(
department_code VARCHAR2(2) NOT NULL,
course_number NUMBER(3,0) NOT NULL,
course_title VARCHAR2(64) NOT NULL,
course_description VARCHAR2(512) NOT NULL,
credits NUMBER(3,1) NOT NULL,
CONSTRAINT pk_courses
PRIMARY KEY (department_code, course_number),
CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code) REFERENCES
departments (department_code) ON DELETE CASCADE
);
Creating foreign key with ON DELETE CASCADE
In Case of ON DELETE CASCADE, if you delete any primary key in
parent table, it will delete the corresponding record from the
child table automatically.
On Delete Cascade continues …
DELETE FROM courses WHERE department_code= ‘PH’;
DELETE FROM departments WHERE department_code= ‘PH’;
COMMIT;
Deleting without ON DELETE CASCADE
To delete a primary key value, no child records can exist
DEFERRED CONSTRAINT
CREATE TABLE courses
(
department_code VARCHAR2(2) NOT NULL,
course_number NUMBER(3,0) NOT NULL,
course_title VARCHAR2(64) NOT NULL,
course_description VARCHAR2(512) NOT NULL,
credits NUMBER(3,1) NOT NULL,
CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number),
CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code)
REFERENCES departments (department_code) DEFERRABLE
INITIALLY IMMEDIATE
-- INITIALLY DEFERRABLE
);
Creating foreign key with DEFERRED CONSTRAINT
This way we can tell oracle to defer enforcing the constraint until
the transaction is commited not as soon as statement is
executed.
DEFERRED CONSTRAINT continues …
CREATE TABLE courses
(
department_code VARCHAR2(2) NOT NULL,
course_number NUMBER(3,0) NOT NULL,
course_title VARCHAR2(64) NOT NULL,
course_description VARCHAR2(512) NOT NULL,
credits NUMBER(3,1) NOT NULL,
CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number),
CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code)
REFERENCES departments (department_code) DEFERRABLE
INITIALLY IMMEDIATE
);
DEFERRED CONSTRAINT with INITIALLY IMMEDIATE
If we use INITIALLY IMMEDIATE, we tell the oracle to enforce the
constraint at statement level like Normal unless we specifically
instruct the oracle to defer checking of the constraint inside of
our transaction.
DEFERRED CONSTRAINT continues …
CREATE TABLE courses
(
department_code VARCHAR2(2) NOT NULL,
course_number NUMBER(3,0) NOT NULL,
course_title VARCHAR2(64) NOT NULL,
course_description VARCHAR2(512) NOT NULL,
credits NUMBER(3,1) NOT NULL,
CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number),
CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code)
REFERENCES departments (department_code) DEFERRABLE
INITIALLY DEFERRABLE
);
DEFERRED CONSTRAINT with INITIALLY DEFERRABLE
If we use INITIALLY DEFERRABLE, we tell the oracle to enforce the
constraint until the transaction commits.
DEFERRED CONSTRAINT continues …
set constraint fk_courses_depatment_code deferred;
UPDATE departments
SET department_code = ‘CO’
WHERE department_code = ‘CS’;
UPDATE courses
SET department_code = ‘CO’
WHERE department_code = ‘CS’;
COMMIT;
Using DEFERRED CONSTRAINT
Check Constraints
CREATE TABLE courses
(
department_code VARCHAR2(2) NOT NULL,
course_number NUMBER(3,0) NOT NULL,
course_title VARCHAR2(64) NOT NULL,
course_description VARCHAR2(512) NOT NULL,
credits NUMBER(3,1) NOT NULL,
CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number),
CONSTRAINT fk_courses_department_code
FOREIGN KEY (department_code) REFERENCES departments (department_code),
CONSTRAINT ck_courses_course_number CHECK (course_number BETWEEN 100 AND 999)
);
Check Constraints continues …
CREATE TABLE states
(
state_code VARCHAR2(2) NOT NULL,
state_name VARCHAR2(30) NOT NULL,
region VARCHAR2(2) NOT NULL,
CONSTRAINT pk_states PRIMARY KEY (state_code),
CONSTRAINT ck_state_regions
CHECK (region IN (‘NE’, ‘SE’, ‘MW’, ‘SC’, ‘NW’, ‘SW’))
);
To Check if a value is within a range
Check Constraints continues …
CREATE TABLE students
(
student_id NUMBER(6) NOT NULL,
first_name VARCHAR2(30) NOT NULL,
last_name VARCHAR2(30) NOT NULL,
email_address VARCHAR2(128) NOT NULL,
likes_ice_cream NUMBER(1) NULL,
CONSTRAINT pk_students PRIMARY KEY (student_id),
CONSTRAINT ck_studens_ice_cream
CHECK (likes_ice_cream IN (0,1))
);
To emulate a Boolean column
Check Constraints continues …
CREATE TABLE zip_codes
(
zip_code VARCHAR2(5) NOT NULL,
city VARCHAR2(30) NOT NULL,
state_code VARCHAR2(30) NOT NULL,
CONSTRAINT pk_codes
PRIMARY KEY (state_code),
CONSTRAINT ck_zip_code_format
CHECK (REGEXP_LIKE (zip_code, '^[0-9]{5}$') )
);
Validate Format Using a Regular Expression
Add a Constraint to an Existing Table
ALTER TABLE zip_codes
ADD CONSTRAINT ck_zip_codes_format
CHECK (REGEXP_LIKE (zip_code, '^[0-9]{5}$') );
Disabling and Enabling Constraints
ALTER TABLE courses
DISABLE CONSTRAINT fk_courses_department_code;
Disabling a constraint
Enabling a constraint
ALTER TABLE courses
ENABLE CONSTRAINT fk_courses_department_code;
Check Constraints continues …
CREATE TABLE zip_codes
(
zip_code VARCHAR2(5) NOT NULL,
city VARCHAR2(30) NOT NULL,
state_code VARCHAR2(30) NOT NULL,
CONSTRAINT pk_codes
PRIMARY KEY (state_code),
CONSTRAINT ck_zip_code_format
CHECK (REGEXP_LIKE (zip_code, '^[0-9]{5}$') )
);
Validate Format Using a Regular Expression
Add a Constraint to an Existing Table
ALTER TABLE zip_codes
ADD CONSTRAINT ck_zip_codes_format
CHECK (REGEXP_LIKE (zip_code, '^[0-9]{5}$') );
Table Storage Options
Oracle stores the tables and views in Database blocks
A Database block is like a shipping container
Table Storage Options
What is a block ?
Block Header
• Block type information
• Object assignment
• Row directory
Row
• Actual data in our tabe
Free space
• Allows for updates to rows.
Table Storage Options
How Oracle Performs Data Access Operation ?
1. Full Table Scan
2. Index operation with Row Lookup.
Full Table Scan
• Oracle scans through every block in the table
• Comparable to a linear search in an array
Table Storage Options
Index Operation with Row lookup
Table Storage Options
Table Data and Sort Order
Data in a table has no implied order.
• Oracle will insert the row wherever they fits
• Physical order in disk != Order data was inserted.
Data returned from queries is not sorted
• Order of results is not order data was returned
• Two different executions can return same results in different
order.
Table Storage Options
Tablespace Introductions
Table Storage Options
Tablespace Block Size
Row Chaining is when a row in table is so long that it will not fit in a single data block.
So oracle has to chain the row and store it in two or more data block.
It increases the amount of IO operation while performing database o/p.
Table Storage Options
Segment space management
Table Storage Options
Oracle Contains Multiple Tablespaces
• Every user has a Default
tablespace
• Some objects may be
created in and alternate
tablespace
Table Storage Options
Specifying a tablespace for a table
CREATE TABLE course_enrollments
(
course_enrollment_id NUMBER NOT NULL,
course_offering_id NUMBER(20) NOT NULL,
student_id NUMBER(10) NOT NULL,
grade_code VARCHAR2(1) NULL,
CONSTRAINT pk_course_enrollments PRIMARY KEY (course_enrollment_id),
CONSTRAINT fk_enrollments_offerings
FOREIGN KEY (course_offering_id) REFERENCES course_offerings(course_offering_id),
CONSTRAINT fk_enrollments_student
FOREIGN KEY (student_id) REFERENCES students (student_id),
CONSTRAINT fk_enrollments_grades FOREIGN KEY (grade_code) REFERENCES grades
(grade_code)
)
TABLESPACE student_data;
Table Storage Options
High Water Mark
Highest numbered block that has ever contained data in a table
• For a newly created table, the block is at the left of the table because no data has
ever been inserted into the table.

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction To MySQL Lecture 1
Introduction To MySQL Lecture 1Introduction To MySQL Lecture 1
Introduction To MySQL Lecture 1Ajay Khatri
 
Sorting Alpha Numeric Data in MySQL
Sorting Alpha Numeric Data in MySQLSorting Alpha Numeric Data in MySQL
Sorting Alpha Numeric Data in MySQLAbdul Rahman Sherzad
 
Using ddl statements to create and manage tables
Using ddl statements to create and manage tablesUsing ddl statements to create and manage tables
Using ddl statements to create and manage tablesSyed Zaid Irshad
 
Using mySQL in PHP
Using mySQL in PHPUsing mySQL in PHP
Using mySQL in PHPMike Crabb
 
Sql Basics | Edureka
Sql Basics | EdurekaSql Basics | Edureka
Sql Basics | EdurekaEdureka!
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)Sabana Maharjan
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinctBishal Ghimire
 
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQLSql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQLPrashant Kumar
 
Intro to tsql unit 7
Intro to tsql   unit 7Intro to tsql   unit 7
Intro to tsql unit 7Syed Asrarali
 
AIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access QueriesAIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access QueriesDan D'Urso
 

Was ist angesagt? (17)

Les09
Les09Les09
Les09
 
Sql commands
Sql commandsSql commands
Sql commands
 
Introduction To MySQL Lecture 1
Introduction To MySQL Lecture 1Introduction To MySQL Lecture 1
Introduction To MySQL Lecture 1
 
Sql
SqlSql
Sql
 
Sorting Alpha Numeric Data in MySQL
Sorting Alpha Numeric Data in MySQLSorting Alpha Numeric Data in MySQL
Sorting Alpha Numeric Data in MySQL
 
MySQL constraints
MySQL constraintsMySQL constraints
MySQL constraints
 
Using ddl statements to create and manage tables
Using ddl statements to create and manage tablesUsing ddl statements to create and manage tables
Using ddl statements to create and manage tables
 
Using mySQL in PHP
Using mySQL in PHPUsing mySQL in PHP
Using mySQL in PHP
 
Sql Basics | Edureka
Sql Basics | EdurekaSql Basics | Edureka
Sql Basics | Edureka
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Sql
SqlSql
Sql
 
MY SQL
MY SQLMY SQL
MY SQL
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinct
 
SImple SQL
SImple SQLSImple SQL
SImple SQL
 
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQLSql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
 
Intro to tsql unit 7
Intro to tsql   unit 7Intro to tsql   unit 7
Intro to tsql unit 7
 
AIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access QueriesAIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access Queries
 

Andere mochten auch

Andere mochten auch (18)

Powerpoint to slideshare
Powerpoint to slidesharePowerpoint to slideshare
Powerpoint to slideshare
 
Iso ruse
Iso ruseIso ruse
Iso ruse
 
F a otsetova_final-26.10.2013
F a otsetova_final-26.10.2013F a otsetova_final-26.10.2013
F a otsetova_final-26.10.2013
 
Tech 2 Assignment
Tech 2 AssignmentTech 2 Assignment
Tech 2 Assignment
 
Fullcomma I Maestri
Fullcomma I MaestriFullcomma I Maestri
Fullcomma I Maestri
 
Maven Fundamentals
Maven FundamentalsMaven Fundamentals
Maven Fundamentals
 
Pdf00001
Pdf00001Pdf00001
Pdf00001
 
Hidrokooloid in bakery
Hidrokooloid in bakeryHidrokooloid in bakery
Hidrokooloid in bakery
 
Kennismaking Flynth Regio Midden
Kennismaking Flynth Regio MiddenKennismaking Flynth Regio Midden
Kennismaking Flynth Regio Midden
 
06 2014-jei-otsetova-enimanev
06 2014-jei-otsetova-enimanev06 2014-jei-otsetova-enimanev
06 2014-jei-otsetova-enimanev
 
06 2014-jei-otsetova-enimanev
06 2014-jei-otsetova-enimanev06 2014-jei-otsetova-enimanev
06 2014-jei-otsetova-enimanev
 
Blog_We have made history together_Paul Druckman FINAL
Blog_We have made history together_Paul Druckman FINALBlog_We have made history together_Paul Druckman FINAL
Blog_We have made history together_Paul Druckman FINAL
 
Holaaa
HolaaaHolaaa
Holaaa
 
Ut 3
Ut 3Ut 3
Ut 3
 
Ut 3 p.
Ut 3 p.Ut 3 p.
Ut 3 p.
 
Ut 3 p.
Ut 3 p.Ut 3 p.
Ut 3 p.
 
Newsletter
NewsletterNewsletter
Newsletter
 
Ut 3
Ut 3Ut 3
Ut 3
 

Ähnlich wie Oracle sql developer essentials

Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Achmad Solichin
 
SESI 2 DATA DEFINITION LANGUAGE.pdf
SESI 2 DATA DEFINITION LANGUAGE.pdfSESI 2 DATA DEFINITION LANGUAGE.pdf
SESI 2 DATA DEFINITION LANGUAGE.pdfbudiman
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinhwebhostingguy
 
Entigrity constraint
Entigrity constraintEntigrity constraint
Entigrity constraintsuman kumar
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql newSANTOSH RATH
 
Most useful queries
Most useful queriesMost useful queries
Most useful queriesSam Depp
 
CIS 336 Final Exam 2 (Devry)
CIS 336 Final Exam 2 (Devry) CIS 336 Final Exam 2 (Devry)
CIS 336 Final Exam 2 (Devry) critter03
 
CIS 336 Final Exam 2 (Devry)p
CIS 336 Final Exam 2 (Devry)pCIS 336 Final Exam 2 (Devry)p
CIS 336 Final Exam 2 (Devry)pcritterc07
 
CIS 336 Final Exam 2 (Devry)s
CIS 336 Final Exam 2 (Devry)sCIS 336 Final Exam 2 (Devry)s
CIS 336 Final Exam 2 (Devry)scritterc07
 
Cis 336 final exam 2
Cis 336 final exam 2Cis 336 final exam 2
Cis 336 final exam 2prasaaanna2
 

Ähnlich wie Oracle sql developer essentials (20)

Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
3. DDL.pdf
3. DDL.pdf3. DDL.pdf
3. DDL.pdf
 
SESI 2 DATA DEFINITION LANGUAGE.pdf
SESI 2 DATA DEFINITION LANGUAGE.pdfSESI 2 DATA DEFINITION LANGUAGE.pdf
SESI 2 DATA DEFINITION LANGUAGE.pdf
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
Les10
Les10Les10
Les10
 
Less08 Schema
Less08 SchemaLess08 Schema
Less08 Schema
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Query
QueryQuery
Query
 
Database
Database Database
Database
 
Entigrity constraint
Entigrity constraintEntigrity constraint
Entigrity constraint
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
zekeLabs sql-slides
zekeLabs sql-slideszekeLabs sql-slides
zekeLabs sql-slides
 
Most useful queries
Most useful queriesMost useful queries
Most useful queries
 
CIS 336 Final Exam 2 (Devry)
CIS 336 Final Exam 2 (Devry) CIS 336 Final Exam 2 (Devry)
CIS 336 Final Exam 2 (Devry)
 
CIS 336 Final Exam 2 (Devry)p
CIS 336 Final Exam 2 (Devry)pCIS 336 Final Exam 2 (Devry)p
CIS 336 Final Exam 2 (Devry)p
 
CIS 336 Final Exam 2 (Devry)s
CIS 336 Final Exam 2 (Devry)sCIS 336 Final Exam 2 (Devry)s
CIS 336 Final Exam 2 (Devry)s
 
Cis 336 final exam 2
Cis 336 final exam 2Cis 336 final exam 2
Cis 336 final exam 2
 

Kürzlich hochgeladen

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Kürzlich hochgeladen (20)

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

Oracle sql developer essentials

  • 2. BASIC CREATE TABLE SYNTAX CREATE TABLE courses ( department_code VARCHAR2(2) NOT NULL, course_number NUMBER(3,0) NOT NULL, course_title VARCHAR2(64) NOT NULL, course_description VARCHAR2(512) NOT NULL, credits NUMBER(3,1) NOT NULL, CONSTRAINT pk_coursesPRIMARY KEY (department_code, course_number), CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code) REFERENCES departments (department_code) CONSTRAINT ck_courses_course_number CHECK (course_numberBETWEEN 100 AND 999) ) TABLESPACE users PCTFREE 75;
  • 3. • Column Naming rules 1. 30 characters maximum 2. Names must be unique withing a table 3. Names can be reused in other table • Number of columns per table 1. Maximum of 1000 columns 2. Over 255 columns result in row chaining Column Definition Rules • Minimum Information 1. Names and datatypes must be specified 2. Null and default clauses are optional
  • 4. CREATE TABLE students ( student_id NUMBER(6) NOT NULL, first_name VARCHAR2(30) NOT NULL, last_name VARCHAR2(30) NOT NULL, email_address VARCHAR2(128) NOT NULL, phone VARCHAR2(20) NULL, city VARCHAR2(30), state VARCHAR2(2) , status_code VARCHAR2(1) DEFAULT ‘A’ NOT NULL, CONSTRAINT pk_studentsPRIMARY KEY (student_id) ); Null column values If not specified , default it will accept null values
  • 5. CREATE TABLE orders ( order_id NUMBER(10) NOT NULL, order_date DATE NOT NULL, customer_id NUMBER(10) NOT NULL, subtotal NUMBER(10,2), tax NUMBER(10,2), shipping NUMBER(10,2), grand_total NUMBER(10,2) AS (subtotal + tax + shipping) VIRTUAL ); Virtual Column • Virtual columns are not stored in physical disk space • You cannot perform insert or update operation on virtual column • Value is computed in the result set of the query • Cannot insert or update virtual columns • Can only make use of columns in the same table • Index can be created over virtual column values
  • 6. CREATE TABLE students ( student_id NUMBER(6) NOT NULL, first_name VARCHAR2(30) NOT NULL, last_name VARCHAR2(30) NOT NULL, email_address VARCHAR2(128) NOT NULL, phone VARCHAR2(20) NULL, city VARCHAR2(30) NULL, state VARCHAR2(2) NULL, CONSTRAINT pk_students PRIMARY KEY (student_id) ); Primary Key • Primary Key Types 1. Natural Key - Combination of naturally occurring columns that forms a unique key 2. Surrogate Key - A unique value is generated for each row • Uniquely Identifies each rows in a column • Can be defined over one or more column • Cannot contain a null value in primary key column
  • 7. CREATE TABLE courses ( department_code VARCHAR2(2) NOT NULL, course_number NUMBER(3,0) NOT NULL, course_title VARCHAR2(64) NOT NULL, course_description VARCHAR2(512) NOT NULL, credits NUMBER(3,1) NOT NULL, CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number) ); Primary Key Using constraint clause Adding Primary Key to an Existing table ALTER TABLE courses CONSTRAINT pk_courses ADD PRIMARY KEY (department_code, course_number);
  • 8. SQL> SELECT rowid, zip_code, city, state 2 FROM zip_codes; ROWID ZIP_C CITY ST ----------------------- -------------------------------- AAAXoNAAGAAAJzeAAA11201 Brooklyn NY AAAXoNAAGAAAJzeAAB75201 Dallas TX AAAXoNAAGAAAJzeAAC80401 Golden CO AAAXoNAAGAAAJzeAAD92101 San Diego CA Oracle ROWID It is not intended to use ROWID as a replacement for primary key.
  • 10. Foreign Key Continues… CREATE TABLE courses ( department_code VARCHAR2(2) NOT NULL, course_number NUMBER(3,0) NOT NULL, course_title VARCHAR2(64) NOT NULL, course_description VARCHAR2(512) NOT NULL, credits NUMBER(3,1) NOT NULL, CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number), C O N S T R A I N T f k _ c o u r s e s _ d e p a r t m e n t _ c o d e F O R E I G N K E Y (d e p a r t m e n t _ c o d e ) R E F E R E N C E S d e p a r t m e n t s (d e p a r t m e n t _ c o d e ) , ); Add a Foreign Key to an Existing Table ALTER TABLE courses CONSTRAINT fk_courses_department_code ADD FOREIGN KEY (department_code) REFERENCES departments (department_code);
  • 11. On Delete Cascade CREATE TABLE courses ( department_code VARCHAR2(2) NOT NULL, course_number NUMBER(3,0) NOT NULL, course_title VARCHAR2(64) NOT NULL, course_description VARCHAR2(512) NOT NULL, credits NUMBER(3,1) NOT NULL, CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number), CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code) REFERENCES departments (department_code) ON DELETE CASCADE ); Creating foreign key with ON DELETE CASCADE In Case of ON DELETE CASCADE, if you delete any primary key in parent table, it will delete the corresponding record from the child table automatically.
  • 12. On Delete Cascade continues … DELETE FROM courses WHERE department_code= ‘PH’; DELETE FROM departments WHERE department_code= ‘PH’; COMMIT; Deleting without ON DELETE CASCADE To delete a primary key value, no child records can exist
  • 13. DEFERRED CONSTRAINT CREATE TABLE courses ( department_code VARCHAR2(2) NOT NULL, course_number NUMBER(3,0) NOT NULL, course_title VARCHAR2(64) NOT NULL, course_description VARCHAR2(512) NOT NULL, credits NUMBER(3,1) NOT NULL, CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number), CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code) REFERENCES departments (department_code) DEFERRABLE INITIALLY IMMEDIATE -- INITIALLY DEFERRABLE ); Creating foreign key with DEFERRED CONSTRAINT This way we can tell oracle to defer enforcing the constraint until the transaction is commited not as soon as statement is executed.
  • 14. DEFERRED CONSTRAINT continues … CREATE TABLE courses ( department_code VARCHAR2(2) NOT NULL, course_number NUMBER(3,0) NOT NULL, course_title VARCHAR2(64) NOT NULL, course_description VARCHAR2(512) NOT NULL, credits NUMBER(3,1) NOT NULL, CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number), CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code) REFERENCES departments (department_code) DEFERRABLE INITIALLY IMMEDIATE ); DEFERRED CONSTRAINT with INITIALLY IMMEDIATE If we use INITIALLY IMMEDIATE, we tell the oracle to enforce the constraint at statement level like Normal unless we specifically instruct the oracle to defer checking of the constraint inside of our transaction.
  • 15. DEFERRED CONSTRAINT continues … CREATE TABLE courses ( department_code VARCHAR2(2) NOT NULL, course_number NUMBER(3,0) NOT NULL, course_title VARCHAR2(64) NOT NULL, course_description VARCHAR2(512) NOT NULL, credits NUMBER(3,1) NOT NULL, CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number), CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code) REFERENCES departments (department_code) DEFERRABLE INITIALLY DEFERRABLE ); DEFERRED CONSTRAINT with INITIALLY DEFERRABLE If we use INITIALLY DEFERRABLE, we tell the oracle to enforce the constraint until the transaction commits.
  • 16. DEFERRED CONSTRAINT continues … set constraint fk_courses_depatment_code deferred; UPDATE departments SET department_code = ‘CO’ WHERE department_code = ‘CS’; UPDATE courses SET department_code = ‘CO’ WHERE department_code = ‘CS’; COMMIT; Using DEFERRED CONSTRAINT
  • 17. Check Constraints CREATE TABLE courses ( department_code VARCHAR2(2) NOT NULL, course_number NUMBER(3,0) NOT NULL, course_title VARCHAR2(64) NOT NULL, course_description VARCHAR2(512) NOT NULL, credits NUMBER(3,1) NOT NULL, CONSTRAINT pk_courses PRIMARY KEY (department_code, course_number), CONSTRAINT fk_courses_department_code FOREIGN KEY (department_code) REFERENCES departments (department_code), CONSTRAINT ck_courses_course_number CHECK (course_number BETWEEN 100 AND 999) );
  • 18. Check Constraints continues … CREATE TABLE states ( state_code VARCHAR2(2) NOT NULL, state_name VARCHAR2(30) NOT NULL, region VARCHAR2(2) NOT NULL, CONSTRAINT pk_states PRIMARY KEY (state_code), CONSTRAINT ck_state_regions CHECK (region IN (‘NE’, ‘SE’, ‘MW’, ‘SC’, ‘NW’, ‘SW’)) ); To Check if a value is within a range
  • 19. Check Constraints continues … CREATE TABLE students ( student_id NUMBER(6) NOT NULL, first_name VARCHAR2(30) NOT NULL, last_name VARCHAR2(30) NOT NULL, email_address VARCHAR2(128) NOT NULL, likes_ice_cream NUMBER(1) NULL, CONSTRAINT pk_students PRIMARY KEY (student_id), CONSTRAINT ck_studens_ice_cream CHECK (likes_ice_cream IN (0,1)) ); To emulate a Boolean column
  • 20. Check Constraints continues … CREATE TABLE zip_codes ( zip_code VARCHAR2(5) NOT NULL, city VARCHAR2(30) NOT NULL, state_code VARCHAR2(30) NOT NULL, CONSTRAINT pk_codes PRIMARY KEY (state_code), CONSTRAINT ck_zip_code_format CHECK (REGEXP_LIKE (zip_code, '^[0-9]{5}$') ) ); Validate Format Using a Regular Expression Add a Constraint to an Existing Table ALTER TABLE zip_codes ADD CONSTRAINT ck_zip_codes_format CHECK (REGEXP_LIKE (zip_code, '^[0-9]{5}$') );
  • 21. Disabling and Enabling Constraints ALTER TABLE courses DISABLE CONSTRAINT fk_courses_department_code; Disabling a constraint Enabling a constraint ALTER TABLE courses ENABLE CONSTRAINT fk_courses_department_code;
  • 22. Check Constraints continues … CREATE TABLE zip_codes ( zip_code VARCHAR2(5) NOT NULL, city VARCHAR2(30) NOT NULL, state_code VARCHAR2(30) NOT NULL, CONSTRAINT pk_codes PRIMARY KEY (state_code), CONSTRAINT ck_zip_code_format CHECK (REGEXP_LIKE (zip_code, '^[0-9]{5}$') ) ); Validate Format Using a Regular Expression Add a Constraint to an Existing Table ALTER TABLE zip_codes ADD CONSTRAINT ck_zip_codes_format CHECK (REGEXP_LIKE (zip_code, '^[0-9]{5}$') );
  • 23. Table Storage Options Oracle stores the tables and views in Database blocks A Database block is like a shipping container
  • 24. Table Storage Options What is a block ? Block Header • Block type information • Object assignment • Row directory Row • Actual data in our tabe Free space • Allows for updates to rows.
  • 25. Table Storage Options How Oracle Performs Data Access Operation ? 1. Full Table Scan 2. Index operation with Row Lookup. Full Table Scan • Oracle scans through every block in the table • Comparable to a linear search in an array
  • 26. Table Storage Options Index Operation with Row lookup
  • 27. Table Storage Options Table Data and Sort Order Data in a table has no implied order. • Oracle will insert the row wherever they fits • Physical order in disk != Order data was inserted. Data returned from queries is not sorted • Order of results is not order data was returned • Two different executions can return same results in different order.
  • 29. Table Storage Options Tablespace Block Size Row Chaining is when a row in table is so long that it will not fit in a single data block. So oracle has to chain the row and store it in two or more data block. It increases the amount of IO operation while performing database o/p.
  • 30. Table Storage Options Segment space management
  • 31. Table Storage Options Oracle Contains Multiple Tablespaces • Every user has a Default tablespace • Some objects may be created in and alternate tablespace
  • 32. Table Storage Options Specifying a tablespace for a table CREATE TABLE course_enrollments ( course_enrollment_id NUMBER NOT NULL, course_offering_id NUMBER(20) NOT NULL, student_id NUMBER(10) NOT NULL, grade_code VARCHAR2(1) NULL, CONSTRAINT pk_course_enrollments PRIMARY KEY (course_enrollment_id), CONSTRAINT fk_enrollments_offerings FOREIGN KEY (course_offering_id) REFERENCES course_offerings(course_offering_id), CONSTRAINT fk_enrollments_student FOREIGN KEY (student_id) REFERENCES students (student_id), CONSTRAINT fk_enrollments_grades FOREIGN KEY (grade_code) REFERENCES grades (grade_code) ) TABLESPACE student_data;
  • 33. Table Storage Options High Water Mark Highest numbered block that has ever contained data in a table • For a newly created table, the block is at the left of the table because no data has ever been inserted into the table.