Overview Classes of datatypes available in Oracle 10g – Character – Numeric – Long, Raw – Dates/Times – Large Objects (LOBs) – ROWID – Specialized 1.

Slides:



Advertisements
Similar presentations
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Advertisements

Introduction to IBM DB2 Keith T. Weber GIS Director- Idaho State University.
Data Definition Language (DDL)
Database Chapters.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
1 A GUIDE TO ORACLE8 CHAPTER 2: Creating and ModifyingDatabaseTables 2.
Oracle spatial – Creating spatial tables Object Relational Model Creating Spatial Tables.
Creating Database Tables © Abdou Illia MIS Spring /21/2015.
Data types and variables
TECNOLOGIAS DE ARMAZENAMENTO DE INFORMAÇÃO ESPACIAL.
Chapter 2 Data Types, Declarations, and Displays
Object Relational Model Creating Spatial Tables. Concepts Describe the schema associated with a spatial layer Explain how spatial data is stored using.
String Escape Sequences
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Oracle9 i Datetime Functions Fresher Learning Program January, 2012.
3-1 Copyright  Oracle Corporation, All rights reserved. SQL Functions FunctionInput arg 1 arg 2 arg n Function performs action OutputResultvalue.
Module 2 Working with Data Types. Module Overview Using Data Types Working with Character Data Converting Data Types Working with Specialized Data Types.
Overview of SQL Server Alka Arora.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Module 4: Data Objects. Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures.
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Daybase (DayCart) Introduction What is ‘Daybase’ ? Oracle Schema Objects. Oracle Datatypes. Simple Example. Demo.
Oracle Database Administration
10 Copyright © 2009, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Sizing Basics  Why Size?  When to size  Sizing issues:  Bits and Bytes  Blocks (aka pages) of Data  Different Data types  Row Size  Table Sizing.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
Oracle 11g: SQL Chapter 10 Selected Single-Row Functions.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 14 Globalization Support in the Database.
Chapter 3 Selected Single-Row Functions and Advanced DML & DDL.
Database Application Development using PL/SQL Programming.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Data Types Lesson 4. Skills Matrix Table A table stores your data. Tables are relational in that they are organized as rows and columns (a matrix). Each.
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
6 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
Week 7 Lecture 2 Globalization Support in the Database.
Conversion Functions.
SQL ORACLE 1. Data Type 2 3 VARCHAR2(size [BYTE | CHAR]) Variable-length character string having maximum length size bytes or characters. Maximum size.
Data types  CHAR (size): This data type is used to store character strings values of fixed length. The size in brackets determines the number of characters.
8 Copyright © 2004, Oracle. All rights reserved. Managing Schema Objects.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
SQL CREATING AND MANAGING TABLES lecture4 1. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically.
Sql DDL queries CS 260 Database Systems.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
1 CS 430 Database Theory Winter 2005 Lecture 10: Introduction to SQL.
Academic Year 2015 Autumn. MODULE CC2006NI: Data Modelling and Database Systems Academic Year 2015 Autumn.
Declaring PL/SQL Variables
Oracle & SQL. Oracle Data Types Character Data Types: Char(2) Varchar (20) Clob: large character string as long as 4GB Bolb and bfile: large amount of.
Gollis University Faculty of Computer Engineering Chapter Five: Retrieval, Functions Instructor: Mukhtar M Ali “Hakaale” BCS.
7 Copyright © 2004, Oracle. All rights reserved. Managing Schema Objects.
PLSQL Cont…. Most Common Oracle Data Types VARCHAR2 –Stores variable-length character data. –Takes a required parameter that specifies a maximum length.
Creating Database Objects
Introduction To Oracle
Module 2: Creating Data Types and Tables
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL
DATABASE MANAGEMENT SYSTEM
What is your Character Data Type?
A JSON’s Journey through SQL Server
C++ Data Types Data Type
Chapter 2: Creating And Modifying Database Tables
Creating and Managing Tables
Creating Database Objects
Database Instructor: Bei Kang.
Introduction to SQL Server and the Structure Query Language
Presentation transcript:

Overview Classes of datatypes available in Oracle 10g – Character – Numeric – Long, Raw – Dates/Times – Large Objects (LOBs) – ROWID – Specialized 1

Usage of Fonts Normal text SQL SYNTAX or ORACLE FUNCTIONS datatype or function parameter datatype or function optional parameter 2

Character Datatypes 4 Datatypes – CHAR and NCHAR Fixed-length character literals NCHAR used to represent Unicode characters (UTF8) Store up to 2,000 bytes – VARCHAR2 and NVARCHAR2 Variable-length character literals Store up to 4,000 bytes – VARCHAR DON’T USE!! But, it is synonymous with the VARCHAR2 datatype Shame on you if you use this datatype, Oracle may change this datatype to use different comparison semantics in the future – LONG (deprecated) Store up to (2 gig -1) of char data 3

Character Datatype Declarations CHAR( size,{BYTE,CHAR ;DEFAULT=BYTE} ) VARCHAR2( size,{BYTE,CHAR ;DEFAULT=BYTE} ) NCHAR( size ) NVCHAR2( size ) Size can also be specified globally in NLS_LENGTH_SEMANTICS 4

Numeric Datatypes 3 Datatypes – NUMBER Fixed or floating point numbers 38 decimal digits of precision Represent from 1x to 9.99 x Variable storage – 1 to 22 bytes per entry – BINARY_FLOAT Stores floats in 32-bit IEEE 754 format – BINARY_DOUBLE Stores floats in 64-bit IEEE 754 format BINARY_FLOAT and BINARY_DOUBLE advantages – Usually faster computations than NUMBER operations – Use less space to hold data IEEE 754 datatype disadvantages – Fixed size may not be optimal use of space 5

Numeric Datatype Declarations NUMBER( precision,size ) 1 <= precision <= <= size <= 127 BINARY_FLOAT BINARY_DOUBLE 6

Numeric Operators and Functions Operators Functions – TO_BINARY_DOUBLE – Convert float or decimal to double – TO_BINARY_FLOAT – Convert double or decimal to float – TO_CHAR – Convert float or double to decimal – TO_NUMBER – Convert a float, double or decimal to a number –Addition –Multiplication –Remainder (modulus) –Subtraction –Division –Square Root –Equality 7

Time / Date Data Datatypes – DATE Stored as {century, year, month, day, hour, minute, second} – TIMESTAMP Same as DATE, but with fractional seconds Specify the number of seconds of precision, up to 9 digits TIMESTAMP WITH TIME ZONE – Stores TIMESTAMP with displacement between local and UTC time TIMESTAMP WITH LOCAL TIME ZONE – Stores TIMESTAMP but time is normalized to time of database upon entry. Query results return time relative to user – INTERVAL YEAR( precision )TO MONTH – INTERVAL MONTH( precision )TO SECOND 8

Date / Time Operators and Functions Operators – Addition, subtraction, equality Functions – ANSI Literal – ‘ ’ – TO_DATE(‘09-SEP-16 16:00’, ‘YY-MON-DD HH24:MI’) – SYSDATE – System Date (current time) – TRUNC (date) – Truncates sets time portion to midnight – INTERVAL YEAR [precision] TO MONTH – INTERVAL DAY TO SECOND 9

RAW and LONG RAW Datatypes Intended for binary data or byte strings not interpreted by Oracle Database Intended to hold binary data such as graphics, documents, etc. Oracle recommends converting these types to LOBs 10

Large Objects About – LOBs are used to store binary files – Query results including LOBs returns LOB locator Datatypes – CLOB and NCLOB Store up to (4 gig -1) * ( DMBS_LOB.GETCHUNCKSIZE ) of char data – BLOB – Binary Large Object Store up to (4 gig -1) of data – BFILE – Binary File Store up to 4 gigabytes of data Stored in a separate file on the server Administrator responsible that the files exist and can be accessed 11

ROWID Datatype Row addresses in Oracle Access row addresses by querying ROWID Extended rowids – Supports partitioned tables and indexes without ambiguity 12

Specialized Datatypes Other types of data that can be represented – Geographic – Multimedia – Searchable Text – XML – Dynamically Typed Data – ANSI/ISO, DB2 and SQL/DS Data 13

Geographic Datatype MDSYS.SDO_GEOMETRY – Must have installed Oracle Spatial – Object created using CREATE TYPE SDO_GEOMETRY AS OBJECT ( SDO_GTYPE NUMBER, SDO_SRID NUMBER, SDO_POINT SDO_POINT_TYPE, SDO_ELEM_INFO SDO_ELEM_INFO_ARRAY, SDO_ORDINATES SDO_ORDINATE_ARRAY); SDO_GTYPE – reference to type of point (line, curve, polygon, etc) SDO_SRID – reference for the spatial coordinate system SDO_POINT – (x,y,z) coordinate of point SDO_ELEM_INFO – SDO_ORDINATES – lkj 14

Regular Expressions Overview Regular expressions are a language for pattern matching within text (string data) Useful when you want to find like strings or to extract information from strings Portable-ish – syntax can be used across applications, though some applications use more a more feature rich syntax than others Syntax is interpreted through a Regex Engine – DFA – Very fast, tends to use more memory, uses longest leftmost matching – NFA – Uses backtracking, exhaustively searches all permutations of the regex 15

Regex Syntax Basics SyntaxNameExampleMatches.Any CharacterO.amaOsama, Obama, Omama +One or more charactersBe+rBer, Beer, Beeeeeeeeeeeeeer ?Zero or OneStuff?Stuf, Stuff *Zero or MoreFoo*Fo, Foo, Fooooooooooooooooo |Alternationcat|batcat, bat {m}Exact CountClas{2}Class {m,}At leastSQ{1,}LSQL, SQQQQQQQQL {m,n}In betweenAp{1,3}leAple, Apple, Appple (…)Grouping, Sub-expression(fa|fi)tfat, fit [...]Character set[bc]atbat, cat [^...]Not in character set[^bc]atfat, hat, ^Beginning of line^TheThe quick brown fox, The lazy dog $End of lines$Sleeps, sleeps, eats \dAny digit\d\d10, 20, 99 \wAny word character\w\w\wwww, w_w, 222 \sAny space character\stab, newline, space, carriage return 16

Regex Functions REGEXP_LIKE( columnName,pattern ) – Used in a WHERE clause to search for a pattern REGEXP_REPLACE( string,pattern,repl,pos,occ,m_param ) – Replaces a matched pattern with a specified string REGEXP_INSTR( string,pattern,pos,occ,ret,m_param ) – Searches for an instance of a pattern and returns the position in the string where that pattern is found REGEXP_SUBSTR( string,pattern,pos,occ,m_param) – Returns a substring matching the regex pattern specified 17

References Oracle 10g Application Developer’s Guide Oracle 10g Call Interface Programmer’s Guide Oracle 10g SQL Reference Oracle 10g Spatial User’s Guide and Reference Mastering Regular Expressions by Jeffrey Friedl Wikipedia – IEEE