+ All Categories
Home > Documents > M_04_1.00 Data Objects and Demos and Labs.pdf

M_04_1.00 Data Objects and Demos and Labs.pdf

Date post: 02-Apr-2018
Category:
Upload: edmundo-lozada
View: 231 times
Download: 0 times
Share this document with a friend

of 20

Transcript
  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    1/20

    Module 4:

    Data Objects

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    2/20

    Overview

    Tables are the main objects that store dataIndexes, views, stored programs and other objects arethe support structures

    Various table types compared based on data

    organization

    Various index types compared

    Native and non-native data type support

    Block-level storage architecture

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    3/20

    Schema Objects Table

    Tables are theprimary objects thatstore data in rowsand columns

    Each DBMS offersdifferent types oftables to supportdifferent accessneeds with optimal

    performance andextendedfunctionality as thegoals

    Oracle SQL Server

    Heap-Organized Table Heap

    Clustered Table Indexed Views

    Partitioned Table Partitioned Table

    Nested TableXML &

    hierarchyid

    Temporary Table Temporary Table

    External Table Linked Server

    Object Table Table Types

    Index-organized Table Clustered Index

    Table Types in Oracle and SQL Server

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    4/20

    Tables

    Heap is the default form of data organization in a table,where data is stored in an unordered manner

    Oracles index organized tables store data in a B-treestructure in primary key order

    SQL Server has clustered index that does the sameOracle and SQL Server offer local and global temporarytables to store transient application data

    Objects can have more than one allocation unit

    Data compression is possible

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    5/20

    Demonstration: Reviewing Large AllocationUnits

    Demonstration:

    Reviewing Large Allocation Units

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    6/20

    SQL Server Table Structures

    Clustered Index Structure in SQL Server

    ________________

    ________________

    ________________

    Index Rows

    ________________

    ________________

    Previous Next

    ________________

    ________________

    ________________

    Index Rows

    ________________

    ________________

    Previous Next

    ________________

    ________________

    ________________

    Index Rows

    ________________

    ________________

    Previous Next

    ________________

    ________________

    ________________

    Index Rows

    ________________

    ________________

    Previous Next

    ________________

    ________________

    ________________

    Data Rows

    ________________

    ________________

    Previous Next

    ________________

    ________________

    ________________

    Data Rows

    ________________

    ________________

    Previous Next

    ________________

    ________________

    ________________

    Data Rows

    ________________

    ________________

    Previous Next

    RootIndid = 1Id

    Sysindexes

    Root

    node

    Intermediate

    level

    Leaf node /

    data pages

    A-Z

    W-ZA-D E-H

    DebraAndy Charlie

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    7/20

    Constraints

    Constraints are dataintegrity rules definedon columns of a table toenforce certainbusiness rules

    Oracle SQL Server

    NOT NULL NOT NULL

    UNIQUE UNIQUE

    PRIMARY KEY PRIMARY KEY

    FOREIGN KEY FOREIGN KEY

    DEFAULT DEFAULT

    CHECK CHECK

    Constraints in Oracle andSQL Server

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    8/20

    Triggers

    Trigger Types Compared

    Feature Oracle SQL Server

    DML INSERT Yes Yes

    DML UPDATE Yes Yes

    DML

    DELETE Yes YesTiming BEFORE Yes Yes (INSTEAD OF)

    Timing AFTER Yes Yes

    Level Row/Statement Statement

    Views INSTEAD OF Yes Yes

    Multiple triggers per action Yes Yes (first/lastspecified)

    DDL Triggers Yes Yes

    Logon Triggers Yes Yes

    Single trigger for multiple actions Yes Yes

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    9/20

    Indexes

    Index Structures in Oracle and SQL Server

    Index scheme Oracle SQL Server

    B-tree Unique Yes Yes

    B-tree Non-unique Yes Yes

    B-tree Composite Yes (32 cols) Yes (16 cols)

    B-tree Ascending Yes Yes

    B-tree Descending Yes Yes

    B-tree Cluster Yes Yes

    B-tree Reverse key Yes No

    B-tree Key compressed Yes No

    B-tree Function-based Yes No

    B-tree Index organized table Yes Yes (clustered)

    B-tree Partitioned Yes No

    Bitmap Yes (30 cols) No

    Bitmap Join Yes No

    xVelocity columnstore Index No Yes

    Invisible Index Yes No

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    10/20

    Views

    Both Oracle and SQL Server offer views based on simple queries

    involving a single table and complex queries based on multipletables

    Indexed views in SQL Server is the only type of view which actuallystores data

    Oracle and SQL Server offer updatable views with INSTEAD OFtriggers and WITH CHECK OPTION constraint

    View Type Oracle SQL Server

    Simple views Yes Yes

    Join views Yes Yes

    Partitioned views Yes YesUpdatable views Yes Yes

    Inline views Yes Yes

    Object views Yes No

    Indexed views No Yes

    View Types in Oracle and SQL Server

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    11/20

    Number Generation and New Names

    CREATE SEQUENCE SomeNewNumbersSTART WITH 0 INCREMENT BY 1

    ORACLE: Sequence ( 0, 1, 2, 3, 4, .

    CREATE SEQUENCE Test.CountBy1START WITH 0 INCREMENT BY 1

    SQL Server: Sequence (0, 1, 2, 3, 4, ..

    CREATE SYNONYM MyProductFOR TheSchema.TheProduct;

    Either: Synonyms

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    12/20

    Character-Based Data Types

    Character-based data types in Oracle and SQL Server

    Oracle SQL ServerData Type Size (bytes) Data Type Number of

    CharsSize in bytes

    Char 1 to 2000 Char 1 to 8000 1 to 8000 fixed

    NChar 1 to 2000 (fewer chars) NChar 1 to 4000 2 to 8000 fixed

    Varchar 1 to 4000 Varchar

    Varchar(max)

    1 to 8000

    1 to 231-1

    0 to 8000

    0 to 2 GB

    NVarchar 1 to 4000 (fewer chars) NVarchar

    NVarchar(max)

    1 to 8000

    1 to 230-1

    0 to 4000

    0 to 2 GB

    Varchar2 1 to 4000

    NVarchar2 1 to 4000 (fewer chars)LONG 1 to 231 Text,

    Varchar(max)1 to 231-1 0 to 2 GB

    CLOB 1 to 232 Text,Varchar(max)

    1 to 231-1 0 to 2 GB

    NCLOB 1 to 232 Ntext,Nvarchar(max)

    1 to 230-1 0 to 2 GB

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    13/20

    Numeric Data Types

    Numeric data types in Oracle and SQL Server

    Oracle SQL Server

    Number(19,0) BigInt

    Int or Number(10,0) Int

    SmallInt or Number(6,0) SmallInt

    Number(3,0) TinyInt

    Number(p,0) Decimal(p,s)

    Number(p,0) Numeric(p,s)

    Float or DoublePrecision orNumber(38)

    Float

    Number(1) Bit

    Number(19,4) Money

    Number(10,4) SmallMoney

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    14/20

    Date and Time Types

    Oracle SQL Server

    Data Type Values Data Type Values

    Date Date and time to seconds SmallDateTime Date and time to seconds

    DateTimeDate and time with fractional seconds to

    1/300 or 3.33 milliseconds

    Calendar 01/01/1753 AD 01/06/9999 AD (DMY)

    Timestamp (TS)Date and time with fractional

    seconds(9 digits)

    DateTime2 (DT2) Date and time with fractional seconds (7digits)

    Timestamp withtime zone (TSTZ)

    Like TS with zones

    Timestamp withlocal time zone

    (TSLTZ)

    Like TS with relative zonesto users

    DateTimeOffset Like DT2 with time zone offsets

    Calendar Julian

    01/01/4712 BCE -

    12/31/4712 CE

    Calendar

    Gregorian 01/01/0001 AD 31/12/9999 AD (DMY)

    Daylight SavingsTime Support

    YesDaylight Savings

    Time SupportNo

    DATE Date only Gregorian

    TIME Time only with fractional seconds(7 digits)

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    15/20

    Binary Data Types

    Oracle SQL Server

    BLOB Image, Varbinary(max)

    Raw Image, Varbinary(max)

    Long Raw Image, Varbinary(max)

    BFile Similar to

    Varbinary(max) Filestream

    BLOB/Raw(n) Binary(n)

    BLOB/Raw(n) Varbinary(n), Varbinary(max)

    Binary data types in Oracle and SQL Server

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    16/20

    Demonstration: Creating a Table

    Demonstration:

    Creating a Table

    Creating a Partitioned Table

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    17/20

    Non-Native Data Types Beyond Relational

    Spatial Hierarchy

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    18/20

    Demonstration: Beyond Relational

    Demonstration:

    Beyond Relational Spatial Data

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    19/20

    Oracle and SQL Server Block-Level Data Organization

    Microsoft SQL

    Server Data Page

    Row

    Offsets

    OracleData Block

    Row Offsets

    Page Header

    Data Row 1

    Data Row 2

    Data Row 3

    Free Space

    Block Header

    Free Space

    Data Row 3

    Data Row 2

    Data Row 13 2 1

    1 2 3

  • 7/27/2019 M_04_1.00 Data Objects and Demos and Labs.pdf

    20/20

    Review

    Reviewed the types of tables found in Oracle anddiscussed equivalents in SQL Server for heaps, indexorganized tables and temporary tables

    Discussed the supporting schema objects such asindexes and views

    Examined the numeric, character and binary data types

    Implementation of user-defined data types in Oracle andSQL Server

    Comparison of block-level data storage


Recommended