Professional Documents
Culture Documents
Oracle 2
Oracle 2
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0
OBJECTIVES
• Introduction
• Elements of SQL
• Operators, Functions
• Format Models
• Commands
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 2
Elements of SQL
• Datatypes
• Nulls
• Pseudocolumns
• Comments
• Database Objects
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 3
Datatypes...
• VARCHAR2 (size)
– Variable length character string with max length of “size” bytes.
– min size 1 byte, max size 4000 bytes.
• CHAR (n)
– Fixed length character string of size “n” bytes
– min size 1byte, max size 255 bytes
• NUMBER (p,s)
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 4
Datatypes...
• LONG
– To store variable length character strings containing up to 2
gigabytes.
– A table cannot contain more than one LONG column.
– Cannot appear in integrity constraints.
– Cannot be indexed.
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 5
Datatypes...
• DATE
– To store date & time.(Century, year, month, day, hour, min, second)
– On specifying a date value without time component, the default time
is 12:00:00 am.
– On specifying a date value without a date component, the default
date is first day of the month.
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 6
Datatypes...
• LOB (Large Objects)
– Similar to LONG & LONG RAW types but differ in:
Can declare more than one LOB column in a table.
The LOB locator is stored in the table column, either with or
without the actual LOB value.
On accessing a LOB value, the locator is returned.
DML operations can be performed on LOB data.
• ROWID
– Each row in the database has an address.
– Values of ROWID column are hexadecimal strings representing the
address of each row.
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 7
Nulls & Pseudocolumns
• NULLS
– A NULL column is a column with no value.
– Can appear on columns of any datatype that are not restricted by
NOT NULL & PRIMARY KEY integrity constraints.
• PSEUDOCOLUMNS
– Behaves like a table column but is actually not stored in a table.
– Can Select but NOT Insert, Update or Delete from a pseudocolumn.
CURRVAL - Returns the current value of a sequence.
NEXTVAL - Increments the sequence & returns the next
value.
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 8
Nulls & Pseudocolumns
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 9
COMMENTS
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 10
Database Objects
• Schema Objects
– A schema is a collection of logical structures of data (schema
objects) owned by a dB user.
– Each user owns a single schema.
– Types of schema objects:
clusters, database links, database triggers
external procedure libraries, index-only tables
indexes, packages, sequences
stored functions, stored procedures
synonyms, tables, views
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 11
Operators, Functions
• Operators
– Arithmetic (+/-/*)
– Character
|| - to concatenate strings
– Logical (AND/OR)
– Comparison
=, !=, ^=, !=, >, <, >=, =<,IN, NOT IN, ANY, ALL
[NOT] BETWEEN, EXISTS, [NOT] LIKE, IS [NOT] NULL
– Set Operators
UNION, UNION ALL, INTERSECT, MINUS.
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 12
Functions
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 13
Number Functions
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 14
Character Functions
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 15
Character Functions
– Length
– Decode
Decode(value, if1, then1, if2, then2, if3, then3…..else)
– Rtrim,Ltrim
Select Rtrim( 'test', 'st') from dual ; ‘te’
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 16
Date Functions
• KNOWN FUNCTIONS
– ADD_MONTHS, LAST_DAY, NEXT_DAY, SYSDATE,
MONTHS_BETWEEN
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 17
Conversion Functions
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 18
Group Functions
• Examples
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 19
FORMAT MODELS
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 20
COMMANDS
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 21
END
www.perotsystems.com Proprietary and confidential. © 2005 Perot Systems. All rights reserved. All registered trademarks are the property of their respective owners. V1.0 22