SlideShare a Scribd company logo
https://ir.linkedin.com/in/masoud-haji-hassan-pour
By:
Masoud Haji Hassan Pour
Date data type
and Globalization
in Oracle
Agenda
• Describe Date data type
• Formatting Date data type
• Arithmetic on Date data type
• Single row functions
• Oracle Globalization
• Date consideration in flashback
Agenda
• Describe Date data type
• Formatting Date data type
• Arithmetic on Date data type
• Single row functions
• Oracle Globalization
• Date consideration in flashback
Describe Date data type
SQL> select sysdate from dual;
SYSDATE
---------
11-FEB-17
DD-MON-RR is default format for retrieving Date data type in oracle and based on
NLS_TERRITORY.
Describe Date data type
Content
Century
Year
Month
Day
Hour
Minute
Second
Describe Date data type
SQL> create table test (c1 date);
Table created.
SQL> insert into test values(sysdate);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from test;
C1
---------
11-FEB-17
SQL> select to_char(c1, 'cc yyyy-mm-dd hh24:mi:ss') as mydate from test;
MYDATE
----------------------
21 2017-02-11 14:07:25
Describe Date data type
Inserting or updating a date value in a table will implicitly use truncated month
SQL> insert into test values (sysdate);
1 row created.
SQL> insert into test values (to_date('12','mi'));
1 row created.
SQL> select to_char(c1, 'cc yyyy-mm-dd hh24:mi:ss') as mydate from test;
MYDATE
----------------------
21 2017-02-11 15:55:38
21 2017-02-01 00:12:00
Describe Date data type
Minimum and Maximum Date value in Oracle:
January 1, 4712 BCE ~ December 31, 9999 CE
Agenda
• Describe Date data type
• Formatting Date data type
• Arithmetic on Date data type
• Single row functions
• Oracle Globalization
• Date consideration in flashback
Formatting Date data type
Format Mask Format Description
DD Day of the month
MON Month of the year
YY Two-digit year
YYYY Four-digit year including century
RR Two-digit year (Year 2000-compliant)
CC Two-digit century
HH Hours with AM and PM
HH24 Twenty-four-hour time
MI Minute
SS Seconds
Formatting Date data type
Example:
SQL> select * from test;
C1
---------
01-NOV-59
12-FEB-17
12-FEB-17
SQL> select to_char(c1, 'cc yyyy-mm-dd
hh24:mi:ss') as mydate from test;
MYDATE
----------------------
20 1959-11-01 00:00:00
21 2017-02-12 08:58:02
21 2017-02-12 08:58:11
SQL> select to_char(c1, 'cc q') as mydate
from test;
MYDA
----
20 4
21 1
21 1
Formatting Date data type
Standard Syntaxes:
to_char(date, [format], [nls_parameter]),
to_date(string, [format], [nls_parameter]),
Formatting Date data type
Date Format Masks for Days, Months, and Years:
Format Element Description Result
Year Case-sensitive spelling of year Twenty Seventeen
Mon Three-letter abbreviation of month Jun
Month Case-sensitive spelling of month June
Dy Three-letter abbreviation of day Mon
Day Case-sensitive spelling of day Monday
Formatting Date data type
Miscellaneous Date Format Masks:
Format Element Description Result
- / . , ? # ! Punctuation marks: 'MM.YY' 09.08
"any character
literal"
Character literals:
'"Week" W "of " Month'
Week 2 of September
TH Positional or ordinal text:
'DDth "of " Month'
12Th of September
SP Spelled out number:
'MmSP Month Yyyysp'
Nine September
Two Thousand Eight
THSP or SPTH Spelled out positional or
ordinal number: 'hh24SpTh'
Fourteenth
Formatting Date data type
Examples:
SQL> select c1 from test;
C1
---------
12-FEB-17
SQL> select to_char(c1,'Day "the "ddth "of" Month YYYY') as mytDate from test;
MYTDATE
--------------------------------------------------------------------------------
Sunday the 12th of February 2017
Formatting Date data type
What is fm?
The names of days and months are automatically padded with spaces. These may be removed using a
modifier to the format mask called the fill mode (fm) operator.
Example:
SQL> select to_char(c1,'Day "the "ddth "of" Month YYYY') as mytDate from test;
MYTDATE
--------------------------------------------------------------------------------
Sunday the 12th of February 2017
SQL> select to_char(c1,'fmDay "the "ddth "of" Month YYYY') as mytDate from test;
MYTDATE
--------------------------------------------------------------------------------
Sunday the 12th of February 2017
Formatting Date data type
Converting between calendars:
to_char(date, [format], [nls_parameter]),
There are two nls_parameters:
1. nls_date_language
2. nls_calendar
Formatting Date data type
1. nls_date_language
The NLS_DATE_LANGUAGE parameter specifies the language for the day and the month names
produced by the TO_CHAR and TO_DATE functions.
2. nls_calendar
Many different calendar systems are in use throughout the world. NLS_CALENDAR specifies which
calendar system Oracle Database uses.
Formatting Date data type
Examples:
SQL> select to_char(c1,'fmDay "of" fmMonth') as mydate from test;
MYDATE
----------------------------------------------------------------------------
Tuesday of March
SQL> select to_char(c1,'fmDay "of" fmMonth','nls_date_language=french') as mydate from test;
MYDATE
------------------------------------------------------------------------
Mardi of Mars
SQL> select to_char(c1,'fmDay "of" fmMonth','nls_date_language=persian') as mydate from test;
select to_char(c1,'fmDay "of" fmMonth','nls_date_language=persian') as mydate from test
*
ORA-12702: invalid NLS parameter string used in SQL function
Formatting Date data type
How to use Persian Calendar in Oracle ?
SQL> select to_char(c1,'ddth "of" fmMonth "of" yyyy') as mydate from test;
MYDATE
----------------------------------------------------
21st of March of 2017
SQL> select to_char(c1,'ddth "of" fmMonth "of" yyyy','nls_calendar=persian') as mydate from test;
MYDATE
------------------------------------------------------------
01st of Farvardin of 1396
SQL> select to_char(c1,'yyyy/mm/dd','nls_calendar=persian') as mydate from test;
MYDATE
----------
1396/01/01
Formatting Date data type
The necessity of using to_date function:
For inserting Date in Date data type columns (best practice)
Note: you could use only string formats for inserting Date data type in column based on
NLS_DATE_FORMAT parameter, otherwise use to_date function.
Formatting Date data type
Examples:
SQL> select * from nls_session_parameters where parameter='NLS_DATE_FORMAT';
PARAMETER VALUE
-------------------- --------------------
NLS_DATE_FORMAT DD-MON-RR
SQL> insert into test values ('1980');
insert into test values ('1980')
*
ORA-01861: literal does not match format string
SQL> alter session set nls_date_format='yyyy';
Session altered.
SQL> insert into test values ('1990');
1 row created.
Formatting Date data type
Examples cont’d:
SQL> select * from nls_session_parameters where parameter='NLS_DATE_FORMAT';
PARAMETER VALUE
------------------------------ --------------------
NLS_DATE_FORMAT yyyy
SQL> insert into test values (to_date('2016-aug-02','yyyy-mon-dd'));
1 row created.
SQL> insert into test values (to_date('2016','yyyy'));
1 row created.
Formatting Date data type
What is fx?
fx specifies an exact match for string and the format mask. When the fx modifier is specified, character items
that do not exactly match the format mask yield an error.
to_date(string, [format], [nls_parameter])
SQL> insert into test values (to_date('25-DEC-10', 'dd-mon-yyyy'));
1 row created.
SQL> insert into test values (to_date('25-DEC-10', 'fxdd-mon-yyyy'));
insert into test values (to_date('25-DEC-10', 'fxdd-mon-yyyy'))
*
ORA-01862: the numeric value does not match the length of the format item
Formatting Date data type
Simplifying the insertion of Persian Date:
SQL> insert into test values (to_date('1363/04/07 10:00','fxyyyy/mm/dd hh24:mi','nls_calendar=persian'));
1 row created.
SQL> select to_char(c1,'fmDay "the" ddth "of" Month yyyy') as mtdate from test;
MTDATE
--------------------------------------------------------------------------------
Thursday the 28th of June 1984
SQL> select to_char(c1,'fmDay "the" ddth "of" Month yyyy','nls_calendar=persian') as mtdate from test;
MTDATE
--------------------------------------------------------------------------------
Thursday the 7th of Tir 1363
Agenda
• Describe Date data type
• Formatting Date data type
• Arithmetic on Date data type
• Single row functions
• Oracle Globalization
• Date consideration in flashback
Arithmetic on Date data type
Which arithmetic supported on Date data type:
Date1 – Date2 = Num1
Date1 + Num1 = Date2
Date1 = Date2 + Num1
Arithmetic on Date data type
Examples:
SQL> select sysdate - (sysdate + 1) as mydate from dual;
MYDATE
----------
-1
SQL> select sysdate + 1 as mydate from dual;
MYDATE
---------
14-FEB-17
As you can see, the standard unit in Oracle date arithmetic is one day.
Arithmetic on Date data type
Fractions of a day:
Precision Day Day Day
1 Day 1 1 1
1 Hour 1/24 1/24 0.0417
1 Min 1/(24x60) 1/1440 0.000694
1 Sec 1/(24x60x60) 1/86400 0.000011574
Arithmetic on Date data type
Examples:
SQL> select to_char(c1,'yyyy/mm/dd hh24:mi:ss') as mydate from test;
MYDATE
-------------------
2014/02/01 00:00:00
Add 5 minutes:
SQL> select to_char(c1 +(5/1440),'yyyy/mm/dd hh24:mi:ss') as mydate from test;
MYDATE
-------------------
2014/02/01 00:05:00
Arithmetic on Date data type
Examples cont’d:
The notation in the second column is most commonly used, because it is so much easier to read. Five
minutes is 5/(24x60), much easier than 5/1440 or 0.00347.
Subtracting 32 Second:
SQL> select to_char(c1-(32/(24*60*60)),'yyyy/mm/dd hh24:mi:ss') as mydate from test;
MYDATE
-------------------
2014/01/31 23:59:28
Arithmetic on Date data type
Oracle date arithmetic with intrinsic functions:
Date / Time Math Time Description
WHERE (date) > sysdate - 7/24; Past 7 hours
WHERE (date) > sysdate - 7; Past 7 days
WHERE (date) > sysdate - 7/1440; Past 7 minutes
13/24 13 hours
1/24/60/60 One second
5/24/60 Five minutes
5/24 Five hours
TRUNC(SYSDATE+1/24,'HH')
One hour starting with the next
hour
Agenda
• Describe Date data type
• Formatting Date data type
• Arithmetic on Date data type
• Single row functions
• Oracle Globalization
• Date consideration in flashback
Single row functions
Some important functions:
MONTHS_BETWEEN
ADD_MONTHS
LAST_DAY
NEXT_DAY
SYSDATE
ROUND
TRUNC
Single row functions
MONTHS_BETWEEN:
The MONTHS_BETWEEN(date1, date2) function returns the number of months between two dates.
SQL> alter session set nls_calendar=persian;
Session altered.
SQL> select months_between('22-Bahman-1394','22-Ordibehesht-1310') as mydate from dual;
MYDATE
----------
1016.93548
Single row functions
ADD_MONTHS:
The ADD_MONTHS(date1, number of months) function returns the date resulting from adding a specified
number of months to a date.
SQL> select add_months('22-Bahman-1394',3) as mydate from dual;
MYDATE
-------------------
22 Ordibehesht 1395
Single row functions
LAST_DAY:
The LAST_DAY(date) function returns the last day of the month that the specified date falls into.
SQL> select last_day(to_date('09-Esfand-1395')) as mydate from dual;
MYDATE
-------------------
30 Esfand 1395
SQL> select last_day(to_date('09-Esfand-1394')) as mydate from dual;
MYDATE
-------------------
29 Esfand 1394
Single row functions
NEXT_DAY:
The NEXT_DAY(date1, day of the week) function returns the date on which the next specified day of the
week falls after the given date.
SQL> select to_char(to_date('09-Esfand-1395'),'fmDay "the" rr/mm/dd') as mydate from dual;
MYDATE
------------------
Monday the 95/12/9
SQL> select to_char(next_day('09-Esfand-1395','Friday'),'fmDay "the" rr/mm/dd') as mydate from dual;
MYDATE
-------------------
Friday the 95/12/13
Single row functions
SYSDATE:
The SYSDATE function takes no parameters and returns a date value that represents the current server
date and time.
SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as mydate from dual;
MYDATE
-------------------
1395/11/26 10:38:24
Single row functions
ROUND:
The ROUND(date, date precision format) function round a given date value to the nearest date precision
format like day, month, or year.
SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as currdate, to_char(round(sysdate,'mm'),'yyyy/m
m/dd hh24:mi:ss') as mydate from dual;
CURRDATE MYDATE
------------------- -------------------
2017/02/14 10:52:59 2017/02/01 00:00:00
SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as currdate, to_char(round(sysdate,'hh'),'yyyy/m
m/dd hh24:mi:ss') as mydate from dual;
CURRDATE MYDATE
------------------- -------------------
2017/02/14 10:53:28 2017/02/14 11:00:00
Single row functions
TRUNC:
The TRUNC(date, date precision format) truncate a given date value to the nearest date precision format
like day, month, or year.
SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as currdate, to_char(trunc(sysdate,'mm'),'yyyy/m
m/dd hh24:mi:ss') as mydate from dual;
CURRDATE MYDATE
------------------- -------------------
2017/02/14 10:57:49 2017/02/01 00:00:00
SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as currdate, to_char(trunc(sysdate,'hh'),'yyyy/mm
/dd hh24:mi:ss') as mydate from dual;
CURRDATE MYDATE
------------------- -------------------
2017/02/14 10:58:07 2017/02/14 10:00:00
Agenda
• Describe Date data type
• Formatting Date data type
• Arithmetic on Date data type
• Single row functions
• Oracle Globalization
• Date consideration in flashback
Oracle Globalization
NLS Parameters:
NLS (National Language Support) parameters determine the locale-specific behavior on both the client
and the server. NLS parameters can be specified in the following ways:
• As initialization parameters on the server
• As environment variables on the client
• With the ALTER SESSION statement
• In SQL functions
Oracle Globalization
As initialization parameters on the server
You can include parameters in the initialization parameter file to specify a default session NLS
environment. These settings have no effect on the client side; they control only the server's behavior.
For example:
NLS_TERRITORY = "CZECH REPUBLIC"
Oracle Globalization
As environment variables on the client
You can use NLS environment variables, which may be platform-dependent, to specify locale-dependent
behavior for the client and also to override the default values set for the session in the initialization param
eter file. For example:
Linux system:
export NLS_DATE_FORMAT="Day yyyy"
Windows system:
set NLS_DATE_FORMAT=yyyy/mm/dd hh24:mi:ss
Oracle Globalization
With the ALTER SESSION statement:
You can use NLS parameters that are set in an ALTER SESSION statement to override the default
values that are set for the session in the initialization parameter file or set by the client with environment
variables.
ALTER SESSION SET NLS_SORT = AZERBAIJANI;
Oracle Globalization
In SQL functions:
You can use NLS parameters explicitly to hardcode NLS behavior within a SQL function. This practice
overrides the default values that are set for the session in the initialization parameter file, client with
environment variables and ALTER SESSION statement.
For example:
TO_CHAR(hiredate, 'DD/MON/YYYY', ' nls_calendar=persian ')
Oracle Globalization
Setting NLS Parameters and Their Priorities:
Priority Method
1 (highest) Explicitly set in SQL functions
2 Set by an ALTER SESSION statement
3 Set as an environment variable
4 Specified in the initialization parameter file
5 Default
Oracle Globalization
Views to find current NLS settings:
• nls_database_parameters
• nls_instance_parameters
• nls_session_parameters
Note: NLS_CHARACTERSET, NLS_NCHAR_CHARACTERSET and NLS_RDBMS_VERSION, there
are only exist in the nls_database_parameter.
Oracle Globalization
Find all valid CHARACTER SET,TERRITORY,LANGUAGE:
Simply with v$nls_valid_values
Example:
SQL> select * from v$nls_valid_values where lower(parameter) ='territory';
PARAMETER VALUE ISDEP
-------------------- ------------------------------ -------------
TERRITORY ECUADOR FALSE
TERRITORY PHILIPPINES FALSE
TERRITORY ALBANIA FALSE
98 rows selected.
Oracle Globalization
Some important NLS parameters:
• NLS_TERRITORY
• NLS_DATE_FORMAT
• NLS_LANGUAGE (mentioned in section two)
• NLS_CALENDER (mentioned in section two)
Oracle Globalization
NLS_TERRITORY:
The territory selection sets defaults for day and week numbering, credit and debit symbols, date formats,
decimal and group numeric separators, and currency symbols. Some of these can have profound effects
on the way your application software will behave.
Parameters American Germany
NLS_TERRITORY american germany
Decimal separator , .
Currency symbol $ €
First day of week Sunday Monday
Oracle Globalization
NLS_TERRITORY:
Example:
alter session set NLS_TERRITORY='germany';
select to_char(8527,'L999G999') as myChar from dual;
€8.527
alter session set NLS_TERRITORY='america';
select to_char(8527,'L999G999') as myChar from dual;
$8,527
Oracle Globalization
NLS_DATE_FORMAT:
The NLS_DATE_FORMAT parameter defines the default date format to use with the TO_CHAR and
TO_DATE functions. The NLS_TERRITORY parameter determines the default value of
NLS_DATE_FORMAT. The value of NLS_DATE_FORMAT can be any valid date format
mask. For example: NLS_DATE_FORMAT = "MM/DD/YYYY“
Country Description Example
Estonia dd.mm.yyyy 28.02.2003
Germany dd-mm-rr 28-02-03
Japan rr-mm-dd 03-02-28
UK dd-mon-rr 28-Feb-03
US dd-mon-rr 28-Feb-03
Agenda
• Describe Date data type
• Formatting Date data type
• Arithmetic on Date data type
• Single row functions
• Oracle Globalization
• Date consideration in flashback
Date consideration in flashback
What is Flashback Technology ?
Oracle Flashback Technology is a group of Oracle Database features that let you view past states of data
base objects or to return database objects to a previous state without using point-in-time media recovery.
Oracle Flashback features use the Automatic Undo Management (AUM) system to obtain metadata and
historical data for transactions. They rely on undo data, which are records of the effects of individual tran
sactions. For example, if a user runs an UPDATE statement to change a salary from 1000 to 1100, then
Oracle Database stores the value 1000 in the undo data.
Date consideration in flashback
Using Oracle Flashback Query (SELECT AS OF)
To use Oracle Flashback Query, use a SELECT statement with an AS OF clause. Oracle Flashback
Query retrieves data as it existed at an earlier time. The query explicitly references a past time through a
time stamp or System Change Number (SCN). It returns committed data that was current at that point in
time.
Uses of Oracle Flashback Query include:
• Recovering lost data or undoing incorrect, committed changes.
For example, if you mistakenly delete or update rows, and then commit them, you can immediately undo
the mistake.
• Comparing current data with the corresponding data at an earlier time.
For example, you can run a daily report that shows the change in data from yesterday. You can compare
individual rows of table data or find intersections or unions of sets of rows.
Date consideration in flashback
Flashback Example:
SQL> select * from countries where country_name='Iran';
no rows selected
SQL> select to_char(sysdate,'rr/mm/dd hh24:mi:ss') as currdate from dual;
CURRDATE
-----------------
17/02/15 15:27:07
SQL> insert into countries values('IR','Iran',4);
1 row created.
Date consideration in flashback
Flashback Example cont’d:
SQL> select to_char(sysdate,'rr/mm/dd hh24:mi:ss') as currdate from dual;
CURRDATE
-----------------
17/02/15 15:28:29
SQL> select * from countries where country_name='Iran';
CO COUNTRY_NAME REGION_ID
-- ---------------------------------------- ----------
IR Iran 4
Date consideration in flashback
Flashback Example cont’d:
SQL> select * from countries as of timestamp to_timestamp('17/02/15 15:27:07','rr/mm/dd hh24:mi:ss')
where country_name='Iran';
no rows selected
flashback table countries to timestamp to_timestamp('17/02/15 15:27:07','rr/mm/dd hh24:mi:ss');
Flashback succeeded.
SQL> select * from countries where country_name='Iran';
no rows selected
Date consideration in flashback
Relative time:
If you specify a relative time by subtracting from the current time on the database host, the past time is re
calculated for each query. For example:
SQL> insert into countries values ('PO','Poland',1);
1 row created.
SQL> select * from countries As of timestamp (systimestamp - interval '1' minute) where country_name='
Poland';
CO COUNTRY_NAME REGION_ID
-- ---------------------------------------- ----------
PO Poland 1
Date consideration in flashback
Arguments which could be passed to relevant flashback:
select * from countries As of timestamp (systimestamp - interval '1' <argument>);
Arguments
Year
Month
Day
Hour
Minute
Second
Date consideration in flashback
Relative or Exact ?
Exact example:
select * from countries As of timestamp to_timestamp('17/02/18 10:49:12', 'rr/mm/dd hh24:mi:ss');
Relative example:
select * from countries As of timestamp (systimestamp - interval '1' minute);
Method Simplicity Accuracy
Exact No Yes
Relative Yes No
References
• https://docs.oracle.com/cd/E11882_01/server.112/e10729/ch4datetime.htm#NLSPG004
• https://docs.oracle.com/cd/E18283_01/server.112/e10729/ch3globenv.htm
• https://docs.oracle.com/cd/E11882_01/appdev.112/e41502/adfns_flashback.htm#ADFNS1008
Question and Answer
https://ir.linkedin.com/in/masoud-haji-hassan-pour
Masoud Haji Hassan Pour
mas.Hassanpour@gmail.com
Thanks
for your attention

More Related Content

What's hot

Sql 3
Sql 3Sql 3
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Sergey Petrunya
 
MySQL Built-In Functions
MySQL Built-In FunctionsMySQL Built-In Functions
MySQL Built-In Functions
SHC
 
Oracle12 - The Top12 Features by NAYA Technologies
Oracle12 - The Top12 Features by NAYA TechnologiesOracle12 - The Top12 Features by NAYA Technologies
Oracle12 - The Top12 Features by NAYA Technologies
NAYATech
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
Sergey Petrunya
 
Histograms: Pre-12c and now
Histograms: Pre-12c and nowHistograms: Pre-12c and now
Histograms: Pre-12c and now
Anju Garg
 
Histograms : Pre-12c and Now
Histograms : Pre-12c and NowHistograms : Pre-12c and Now
Histograms : Pre-12c and Now
Anju Garg
 
Oracle sql ppt1
Oracle sql ppt1Oracle sql ppt1
Oracle sql ppt1
Madhavendra Dutt
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2
Sergey Petrunya
 

What's hot (9)

Sql 3
Sql 3Sql 3
Sql 3
 
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
 
MySQL Built-In Functions
MySQL Built-In FunctionsMySQL Built-In Functions
MySQL Built-In Functions
 
Oracle12 - The Top12 Features by NAYA Technologies
Oracle12 - The Top12 Features by NAYA TechnologiesOracle12 - The Top12 Features by NAYA Technologies
Oracle12 - The Top12 Features by NAYA Technologies
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
 
Histograms: Pre-12c and now
Histograms: Pre-12c and nowHistograms: Pre-12c and now
Histograms: Pre-12c and now
 
Histograms : Pre-12c and Now
Histograms : Pre-12c and NowHistograms : Pre-12c and Now
Histograms : Pre-12c and Now
 
Oracle sql ppt1
Oracle sql ppt1Oracle sql ppt1
Oracle sql ppt1
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2
 

Viewers also liked

Stained glass
Stained glassStained glass
Stained glass
Brooke Nelson
 
Globalization in HRP
Globalization in HRPGlobalization in HRP
Globalization in HRP
GLewis16
 
Globalization
GlobalizationGlobalization
Globalization
Jose Fadul
 
HDD docking station
HDD docking stationHDD docking station
HDD docking station
Gurin Products, LLC
 
10. pertemuan 9 (pemodelan ahp)
10. pertemuan 9 (pemodelan ahp)10. pertemuan 9 (pemodelan ahp)
10. pertemuan 9 (pemodelan ahp)
iqbal vidianto
 
Ir meaning, nature and importance
Ir  meaning, nature and importanceIr  meaning, nature and importance
Ir meaning, nature and importance
Asad Ali
 
WWI presentation
WWI presentationWWI presentation
WWI presentation
bharris20
 
WWI Powerpoint
WWI PowerpointWWI Powerpoint
WWI Powerpoint
leonardstern
 
WORLD WAR 1 CAUSES AND EFFECTS
WORLD WAR 1 CAUSES AND EFFECTSWORLD WAR 1 CAUSES AND EFFECTS
WORLD WAR 1 CAUSES AND EFFECTS
Jason Pacaway
 
Globalisation slideshare
Globalisation slideshareGlobalisation slideshare
Globalisation slideshare
Kennedy Machete
 
The Causes and Effects of Globalisation
The Causes and Effects of GlobalisationThe Causes and Effects of Globalisation
The Causes and Effects of Globalisation
Aisling O Connor
 
Globalization powerpoint
Globalization powerpointGlobalization powerpoint
Globalization powerpoint
shelbbb527
 
WW1 WW2
WW1 WW2WW1 WW2
WW1 WW2
mitchellfucn
 
Introduciton to international relation
Introduciton to international relationIntroduciton to international relation
Introduciton to international relation
Anjan Kumar Dahal
 
Globalisation ppt 2
Globalisation ppt 2Globalisation ppt 2
Globalisation ppt 2
Ravi Chaurasiya
 
World War II Power Point
World War II Power PointWorld War II Power Point
World War II Power Point
janetdiederich
 

Viewers also liked (17)

Stained glass
Stained glassStained glass
Stained glass
 
Globalization in HRP
Globalization in HRPGlobalization in HRP
Globalization in HRP
 
Globalization
GlobalizationGlobalization
Globalization
 
HDD docking station
HDD docking stationHDD docking station
HDD docking station
 
10. pertemuan 9 (pemodelan ahp)
10. pertemuan 9 (pemodelan ahp)10. pertemuan 9 (pemodelan ahp)
10. pertemuan 9 (pemodelan ahp)
 
Format buku agenda
Format buku agendaFormat buku agenda
Format buku agenda
 
Ir meaning, nature and importance
Ir  meaning, nature and importanceIr  meaning, nature and importance
Ir meaning, nature and importance
 
WWI presentation
WWI presentationWWI presentation
WWI presentation
 
WWI Powerpoint
WWI PowerpointWWI Powerpoint
WWI Powerpoint
 
WORLD WAR 1 CAUSES AND EFFECTS
WORLD WAR 1 CAUSES AND EFFECTSWORLD WAR 1 CAUSES AND EFFECTS
WORLD WAR 1 CAUSES AND EFFECTS
 
Globalisation slideshare
Globalisation slideshareGlobalisation slideshare
Globalisation slideshare
 
The Causes and Effects of Globalisation
The Causes and Effects of GlobalisationThe Causes and Effects of Globalisation
The Causes and Effects of Globalisation
 
Globalization powerpoint
Globalization powerpointGlobalization powerpoint
Globalization powerpoint
 
WW1 WW2
WW1 WW2WW1 WW2
WW1 WW2
 
Introduciton to international relation
Introduciton to international relationIntroduciton to international relation
Introduciton to international relation
 
Globalisation ppt 2
Globalisation ppt 2Globalisation ppt 2
Globalisation ppt 2
 
World War II Power Point
World War II Power PointWorld War II Power Point
World War II Power Point
 

Similar to Date data type and Globalization in Oracle

Sql queries
Sql queriesSql queries
Sql queries
narendrababuc
 
5 Cool Things About SQL
5 Cool Things About SQL5 Cool Things About SQL
5 Cool Things About SQL
Connor McDonald
 
Common Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsCommon Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo apps
Odoo
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
Andrej Pashchenko
 
SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所
Hiroshi Sekiguchi
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
Compare Infobase Limited
 
MariaDB Temporal Tables
MariaDB Temporal TablesMariaDB Temporal Tables
MariaDB Temporal Tables
Federico Razzoli
 
Les03 Single Row Function
Les03 Single Row FunctionLes03 Single Row Function
Advance MySQL Training by Pratyush Majumdar
Advance MySQL Training by Pratyush MajumdarAdvance MySQL Training by Pratyush Majumdar
Advance MySQL Training by Pratyush Majumdar
Pratyush Majumdar
 
A few things about the Oracle optimizer - 2013
A few things about the Oracle optimizer - 2013A few things about the Oracle optimizer - 2013
A few things about the Oracle optimizer - 2013
Connor McDonald
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdf
PraveenPolu1
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
University of Illinois,Chicago
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
University of Illinois,Chicago
 
Datawarehousing_Project_using_MS SQL server.
Datawarehousing_Project_using_MS SQL server.Datawarehousing_Project_using_MS SQL server.
Datawarehousing_Project_using_MS SQL server.
Sushil kasar
 
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Nelson Calero
 
Oracle Database 12c - Data Redaction
Oracle Database 12c - Data RedactionOracle Database 12c - Data Redaction
Oracle Database 12c - Data Redaction
Alex Zaballa
 
M|18 Querying Data at a Previous Point in Time
M|18 Querying Data at a Previous Point in TimeM|18 Querying Data at a Previous Point in Time
M|18 Querying Data at a Previous Point in Time
MariaDB plc
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
Valeriy Kravchuk
 
12c Mini Lesson - Data Redaction
12c Mini Lesson - Data Redaction12c Mini Lesson - Data Redaction
12c Mini Lesson - Data Redaction
Connor McDonald
 
Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1
Ronald Francisco Vargas Quesada
 

Similar to Date data type and Globalization in Oracle (20)

Sql queries
Sql queriesSql queries
Sql queries
 
5 Cool Things About SQL
5 Cool Things About SQL5 Cool Things About SQL
5 Cool Things About SQL
 
Common Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsCommon Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo apps
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
 
SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
 
MariaDB Temporal Tables
MariaDB Temporal TablesMariaDB Temporal Tables
MariaDB Temporal Tables
 
Les03 Single Row Function
Les03 Single Row FunctionLes03 Single Row Function
Les03 Single Row Function
 
Advance MySQL Training by Pratyush Majumdar
Advance MySQL Training by Pratyush MajumdarAdvance MySQL Training by Pratyush Majumdar
Advance MySQL Training by Pratyush Majumdar
 
A few things about the Oracle optimizer - 2013
A few things about the Oracle optimizer - 2013A few things about the Oracle optimizer - 2013
A few things about the Oracle optimizer - 2013
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdf
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
 
Datawarehousing_Project_using_MS SQL server.
Datawarehousing_Project_using_MS SQL server.Datawarehousing_Project_using_MS SQL server.
Datawarehousing_Project_using_MS SQL server.
 
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
 
Oracle Database 12c - Data Redaction
Oracle Database 12c - Data RedactionOracle Database 12c - Data Redaction
Oracle Database 12c - Data Redaction
 
M|18 Querying Data at a Previous Point in Time
M|18 Querying Data at a Previous Point in TimeM|18 Querying Data at a Previous Point in Time
M|18 Querying Data at a Previous Point in Time
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
 
12c Mini Lesson - Data Redaction
12c Mini Lesson - Data Redaction12c Mini Lesson - Data Redaction
12c Mini Lesson - Data Redaction
 
Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1
 

Recently uploaded

Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 

Recently uploaded (20)

Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 

Date data type and Globalization in Oracle

  • 1. https://ir.linkedin.com/in/masoud-haji-hassan-pour By: Masoud Haji Hassan Pour Date data type and Globalization in Oracle
  • 2. Agenda • Describe Date data type • Formatting Date data type • Arithmetic on Date data type • Single row functions • Oracle Globalization • Date consideration in flashback
  • 3. Agenda • Describe Date data type • Formatting Date data type • Arithmetic on Date data type • Single row functions • Oracle Globalization • Date consideration in flashback
  • 4. Describe Date data type SQL> select sysdate from dual; SYSDATE --------- 11-FEB-17 DD-MON-RR is default format for retrieving Date data type in oracle and based on NLS_TERRITORY.
  • 5. Describe Date data type Content Century Year Month Day Hour Minute Second
  • 6. Describe Date data type SQL> create table test (c1 date); Table created. SQL> insert into test values(sysdate); 1 row created. SQL> commit; Commit complete. SQL> select * from test; C1 --------- 11-FEB-17 SQL> select to_char(c1, 'cc yyyy-mm-dd hh24:mi:ss') as mydate from test; MYDATE ---------------------- 21 2017-02-11 14:07:25
  • 7. Describe Date data type Inserting or updating a date value in a table will implicitly use truncated month SQL> insert into test values (sysdate); 1 row created. SQL> insert into test values (to_date('12','mi')); 1 row created. SQL> select to_char(c1, 'cc yyyy-mm-dd hh24:mi:ss') as mydate from test; MYDATE ---------------------- 21 2017-02-11 15:55:38 21 2017-02-01 00:12:00
  • 8. Describe Date data type Minimum and Maximum Date value in Oracle: January 1, 4712 BCE ~ December 31, 9999 CE
  • 9. Agenda • Describe Date data type • Formatting Date data type • Arithmetic on Date data type • Single row functions • Oracle Globalization • Date consideration in flashback
  • 10. Formatting Date data type Format Mask Format Description DD Day of the month MON Month of the year YY Two-digit year YYYY Four-digit year including century RR Two-digit year (Year 2000-compliant) CC Two-digit century HH Hours with AM and PM HH24 Twenty-four-hour time MI Minute SS Seconds
  • 11. Formatting Date data type Example: SQL> select * from test; C1 --------- 01-NOV-59 12-FEB-17 12-FEB-17 SQL> select to_char(c1, 'cc yyyy-mm-dd hh24:mi:ss') as mydate from test; MYDATE ---------------------- 20 1959-11-01 00:00:00 21 2017-02-12 08:58:02 21 2017-02-12 08:58:11 SQL> select to_char(c1, 'cc q') as mydate from test; MYDA ---- 20 4 21 1 21 1
  • 12. Formatting Date data type Standard Syntaxes: to_char(date, [format], [nls_parameter]), to_date(string, [format], [nls_parameter]),
  • 13. Formatting Date data type Date Format Masks for Days, Months, and Years: Format Element Description Result Year Case-sensitive spelling of year Twenty Seventeen Mon Three-letter abbreviation of month Jun Month Case-sensitive spelling of month June Dy Three-letter abbreviation of day Mon Day Case-sensitive spelling of day Monday
  • 14. Formatting Date data type Miscellaneous Date Format Masks: Format Element Description Result - / . , ? # ! Punctuation marks: 'MM.YY' 09.08 "any character literal" Character literals: '"Week" W "of " Month' Week 2 of September TH Positional or ordinal text: 'DDth "of " Month' 12Th of September SP Spelled out number: 'MmSP Month Yyyysp' Nine September Two Thousand Eight THSP or SPTH Spelled out positional or ordinal number: 'hh24SpTh' Fourteenth
  • 15. Formatting Date data type Examples: SQL> select c1 from test; C1 --------- 12-FEB-17 SQL> select to_char(c1,'Day "the "ddth "of" Month YYYY') as mytDate from test; MYTDATE -------------------------------------------------------------------------------- Sunday the 12th of February 2017
  • 16. Formatting Date data type What is fm? The names of days and months are automatically padded with spaces. These may be removed using a modifier to the format mask called the fill mode (fm) operator. Example: SQL> select to_char(c1,'Day "the "ddth "of" Month YYYY') as mytDate from test; MYTDATE -------------------------------------------------------------------------------- Sunday the 12th of February 2017 SQL> select to_char(c1,'fmDay "the "ddth "of" Month YYYY') as mytDate from test; MYTDATE -------------------------------------------------------------------------------- Sunday the 12th of February 2017
  • 17. Formatting Date data type Converting between calendars: to_char(date, [format], [nls_parameter]), There are two nls_parameters: 1. nls_date_language 2. nls_calendar
  • 18. Formatting Date data type 1. nls_date_language The NLS_DATE_LANGUAGE parameter specifies the language for the day and the month names produced by the TO_CHAR and TO_DATE functions. 2. nls_calendar Many different calendar systems are in use throughout the world. NLS_CALENDAR specifies which calendar system Oracle Database uses.
  • 19. Formatting Date data type Examples: SQL> select to_char(c1,'fmDay "of" fmMonth') as mydate from test; MYDATE ---------------------------------------------------------------------------- Tuesday of March SQL> select to_char(c1,'fmDay "of" fmMonth','nls_date_language=french') as mydate from test; MYDATE ------------------------------------------------------------------------ Mardi of Mars SQL> select to_char(c1,'fmDay "of" fmMonth','nls_date_language=persian') as mydate from test; select to_char(c1,'fmDay "of" fmMonth','nls_date_language=persian') as mydate from test * ORA-12702: invalid NLS parameter string used in SQL function
  • 20. Formatting Date data type How to use Persian Calendar in Oracle ? SQL> select to_char(c1,'ddth "of" fmMonth "of" yyyy') as mydate from test; MYDATE ---------------------------------------------------- 21st of March of 2017 SQL> select to_char(c1,'ddth "of" fmMonth "of" yyyy','nls_calendar=persian') as mydate from test; MYDATE ------------------------------------------------------------ 01st of Farvardin of 1396 SQL> select to_char(c1,'yyyy/mm/dd','nls_calendar=persian') as mydate from test; MYDATE ---------- 1396/01/01
  • 21. Formatting Date data type The necessity of using to_date function: For inserting Date in Date data type columns (best practice) Note: you could use only string formats for inserting Date data type in column based on NLS_DATE_FORMAT parameter, otherwise use to_date function.
  • 22. Formatting Date data type Examples: SQL> select * from nls_session_parameters where parameter='NLS_DATE_FORMAT'; PARAMETER VALUE -------------------- -------------------- NLS_DATE_FORMAT DD-MON-RR SQL> insert into test values ('1980'); insert into test values ('1980') * ORA-01861: literal does not match format string SQL> alter session set nls_date_format='yyyy'; Session altered. SQL> insert into test values ('1990'); 1 row created.
  • 23. Formatting Date data type Examples cont’d: SQL> select * from nls_session_parameters where parameter='NLS_DATE_FORMAT'; PARAMETER VALUE ------------------------------ -------------------- NLS_DATE_FORMAT yyyy SQL> insert into test values (to_date('2016-aug-02','yyyy-mon-dd')); 1 row created. SQL> insert into test values (to_date('2016','yyyy')); 1 row created.
  • 24. Formatting Date data type What is fx? fx specifies an exact match for string and the format mask. When the fx modifier is specified, character items that do not exactly match the format mask yield an error. to_date(string, [format], [nls_parameter]) SQL> insert into test values (to_date('25-DEC-10', 'dd-mon-yyyy')); 1 row created. SQL> insert into test values (to_date('25-DEC-10', 'fxdd-mon-yyyy')); insert into test values (to_date('25-DEC-10', 'fxdd-mon-yyyy')) * ORA-01862: the numeric value does not match the length of the format item
  • 25. Formatting Date data type Simplifying the insertion of Persian Date: SQL> insert into test values (to_date('1363/04/07 10:00','fxyyyy/mm/dd hh24:mi','nls_calendar=persian')); 1 row created. SQL> select to_char(c1,'fmDay "the" ddth "of" Month yyyy') as mtdate from test; MTDATE -------------------------------------------------------------------------------- Thursday the 28th of June 1984 SQL> select to_char(c1,'fmDay "the" ddth "of" Month yyyy','nls_calendar=persian') as mtdate from test; MTDATE -------------------------------------------------------------------------------- Thursday the 7th of Tir 1363
  • 26. Agenda • Describe Date data type • Formatting Date data type • Arithmetic on Date data type • Single row functions • Oracle Globalization • Date consideration in flashback
  • 27. Arithmetic on Date data type Which arithmetic supported on Date data type: Date1 – Date2 = Num1 Date1 + Num1 = Date2 Date1 = Date2 + Num1
  • 28. Arithmetic on Date data type Examples: SQL> select sysdate - (sysdate + 1) as mydate from dual; MYDATE ---------- -1 SQL> select sysdate + 1 as mydate from dual; MYDATE --------- 14-FEB-17 As you can see, the standard unit in Oracle date arithmetic is one day.
  • 29. Arithmetic on Date data type Fractions of a day: Precision Day Day Day 1 Day 1 1 1 1 Hour 1/24 1/24 0.0417 1 Min 1/(24x60) 1/1440 0.000694 1 Sec 1/(24x60x60) 1/86400 0.000011574
  • 30. Arithmetic on Date data type Examples: SQL> select to_char(c1,'yyyy/mm/dd hh24:mi:ss') as mydate from test; MYDATE ------------------- 2014/02/01 00:00:00 Add 5 minutes: SQL> select to_char(c1 +(5/1440),'yyyy/mm/dd hh24:mi:ss') as mydate from test; MYDATE ------------------- 2014/02/01 00:05:00
  • 31. Arithmetic on Date data type Examples cont’d: The notation in the second column is most commonly used, because it is so much easier to read. Five minutes is 5/(24x60), much easier than 5/1440 or 0.00347. Subtracting 32 Second: SQL> select to_char(c1-(32/(24*60*60)),'yyyy/mm/dd hh24:mi:ss') as mydate from test; MYDATE ------------------- 2014/01/31 23:59:28
  • 32. Arithmetic on Date data type Oracle date arithmetic with intrinsic functions: Date / Time Math Time Description WHERE (date) > sysdate - 7/24; Past 7 hours WHERE (date) > sysdate - 7; Past 7 days WHERE (date) > sysdate - 7/1440; Past 7 minutes 13/24 13 hours 1/24/60/60 One second 5/24/60 Five minutes 5/24 Five hours TRUNC(SYSDATE+1/24,'HH') One hour starting with the next hour
  • 33. Agenda • Describe Date data type • Formatting Date data type • Arithmetic on Date data type • Single row functions • Oracle Globalization • Date consideration in flashback
  • 34. Single row functions Some important functions: MONTHS_BETWEEN ADD_MONTHS LAST_DAY NEXT_DAY SYSDATE ROUND TRUNC
  • 35. Single row functions MONTHS_BETWEEN: The MONTHS_BETWEEN(date1, date2) function returns the number of months between two dates. SQL> alter session set nls_calendar=persian; Session altered. SQL> select months_between('22-Bahman-1394','22-Ordibehesht-1310') as mydate from dual; MYDATE ---------- 1016.93548
  • 36. Single row functions ADD_MONTHS: The ADD_MONTHS(date1, number of months) function returns the date resulting from adding a specified number of months to a date. SQL> select add_months('22-Bahman-1394',3) as mydate from dual; MYDATE ------------------- 22 Ordibehesht 1395
  • 37. Single row functions LAST_DAY: The LAST_DAY(date) function returns the last day of the month that the specified date falls into. SQL> select last_day(to_date('09-Esfand-1395')) as mydate from dual; MYDATE ------------------- 30 Esfand 1395 SQL> select last_day(to_date('09-Esfand-1394')) as mydate from dual; MYDATE ------------------- 29 Esfand 1394
  • 38. Single row functions NEXT_DAY: The NEXT_DAY(date1, day of the week) function returns the date on which the next specified day of the week falls after the given date. SQL> select to_char(to_date('09-Esfand-1395'),'fmDay "the" rr/mm/dd') as mydate from dual; MYDATE ------------------ Monday the 95/12/9 SQL> select to_char(next_day('09-Esfand-1395','Friday'),'fmDay "the" rr/mm/dd') as mydate from dual; MYDATE ------------------- Friday the 95/12/13
  • 39. Single row functions SYSDATE: The SYSDATE function takes no parameters and returns a date value that represents the current server date and time. SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as mydate from dual; MYDATE ------------------- 1395/11/26 10:38:24
  • 40. Single row functions ROUND: The ROUND(date, date precision format) function round a given date value to the nearest date precision format like day, month, or year. SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as currdate, to_char(round(sysdate,'mm'),'yyyy/m m/dd hh24:mi:ss') as mydate from dual; CURRDATE MYDATE ------------------- ------------------- 2017/02/14 10:52:59 2017/02/01 00:00:00 SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as currdate, to_char(round(sysdate,'hh'),'yyyy/m m/dd hh24:mi:ss') as mydate from dual; CURRDATE MYDATE ------------------- ------------------- 2017/02/14 10:53:28 2017/02/14 11:00:00
  • 41. Single row functions TRUNC: The TRUNC(date, date precision format) truncate a given date value to the nearest date precision format like day, month, or year. SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as currdate, to_char(trunc(sysdate,'mm'),'yyyy/m m/dd hh24:mi:ss') as mydate from dual; CURRDATE MYDATE ------------------- ------------------- 2017/02/14 10:57:49 2017/02/01 00:00:00 SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as currdate, to_char(trunc(sysdate,'hh'),'yyyy/mm /dd hh24:mi:ss') as mydate from dual; CURRDATE MYDATE ------------------- ------------------- 2017/02/14 10:58:07 2017/02/14 10:00:00
  • 42. Agenda • Describe Date data type • Formatting Date data type • Arithmetic on Date data type • Single row functions • Oracle Globalization • Date consideration in flashback
  • 43. Oracle Globalization NLS Parameters: NLS (National Language Support) parameters determine the locale-specific behavior on both the client and the server. NLS parameters can be specified in the following ways: • As initialization parameters on the server • As environment variables on the client • With the ALTER SESSION statement • In SQL functions
  • 44. Oracle Globalization As initialization parameters on the server You can include parameters in the initialization parameter file to specify a default session NLS environment. These settings have no effect on the client side; they control only the server's behavior. For example: NLS_TERRITORY = "CZECH REPUBLIC"
  • 45. Oracle Globalization As environment variables on the client You can use NLS environment variables, which may be platform-dependent, to specify locale-dependent behavior for the client and also to override the default values set for the session in the initialization param eter file. For example: Linux system: export NLS_DATE_FORMAT="Day yyyy" Windows system: set NLS_DATE_FORMAT=yyyy/mm/dd hh24:mi:ss
  • 46. Oracle Globalization With the ALTER SESSION statement: You can use NLS parameters that are set in an ALTER SESSION statement to override the default values that are set for the session in the initialization parameter file or set by the client with environment variables. ALTER SESSION SET NLS_SORT = AZERBAIJANI;
  • 47. Oracle Globalization In SQL functions: You can use NLS parameters explicitly to hardcode NLS behavior within a SQL function. This practice overrides the default values that are set for the session in the initialization parameter file, client with environment variables and ALTER SESSION statement. For example: TO_CHAR(hiredate, 'DD/MON/YYYY', ' nls_calendar=persian ')
  • 48. Oracle Globalization Setting NLS Parameters and Their Priorities: Priority Method 1 (highest) Explicitly set in SQL functions 2 Set by an ALTER SESSION statement 3 Set as an environment variable 4 Specified in the initialization parameter file 5 Default
  • 49. Oracle Globalization Views to find current NLS settings: • nls_database_parameters • nls_instance_parameters • nls_session_parameters Note: NLS_CHARACTERSET, NLS_NCHAR_CHARACTERSET and NLS_RDBMS_VERSION, there are only exist in the nls_database_parameter.
  • 50. Oracle Globalization Find all valid CHARACTER SET,TERRITORY,LANGUAGE: Simply with v$nls_valid_values Example: SQL> select * from v$nls_valid_values where lower(parameter) ='territory'; PARAMETER VALUE ISDEP -------------------- ------------------------------ ------------- TERRITORY ECUADOR FALSE TERRITORY PHILIPPINES FALSE TERRITORY ALBANIA FALSE 98 rows selected.
  • 51. Oracle Globalization Some important NLS parameters: • NLS_TERRITORY • NLS_DATE_FORMAT • NLS_LANGUAGE (mentioned in section two) • NLS_CALENDER (mentioned in section two)
  • 52. Oracle Globalization NLS_TERRITORY: The territory selection sets defaults for day and week numbering, credit and debit symbols, date formats, decimal and group numeric separators, and currency symbols. Some of these can have profound effects on the way your application software will behave. Parameters American Germany NLS_TERRITORY american germany Decimal separator , . Currency symbol $ € First day of week Sunday Monday
  • 53. Oracle Globalization NLS_TERRITORY: Example: alter session set NLS_TERRITORY='germany'; select to_char(8527,'L999G999') as myChar from dual; €8.527 alter session set NLS_TERRITORY='america'; select to_char(8527,'L999G999') as myChar from dual; $8,527
  • 54. Oracle Globalization NLS_DATE_FORMAT: The NLS_DATE_FORMAT parameter defines the default date format to use with the TO_CHAR and TO_DATE functions. The NLS_TERRITORY parameter determines the default value of NLS_DATE_FORMAT. The value of NLS_DATE_FORMAT can be any valid date format mask. For example: NLS_DATE_FORMAT = "MM/DD/YYYY“ Country Description Example Estonia dd.mm.yyyy 28.02.2003 Germany dd-mm-rr 28-02-03 Japan rr-mm-dd 03-02-28 UK dd-mon-rr 28-Feb-03 US dd-mon-rr 28-Feb-03
  • 55. Agenda • Describe Date data type • Formatting Date data type • Arithmetic on Date data type • Single row functions • Oracle Globalization • Date consideration in flashback
  • 56. Date consideration in flashback What is Flashback Technology ? Oracle Flashback Technology is a group of Oracle Database features that let you view past states of data base objects or to return database objects to a previous state without using point-in-time media recovery. Oracle Flashback features use the Automatic Undo Management (AUM) system to obtain metadata and historical data for transactions. They rely on undo data, which are records of the effects of individual tran sactions. For example, if a user runs an UPDATE statement to change a salary from 1000 to 1100, then Oracle Database stores the value 1000 in the undo data.
  • 57. Date consideration in flashback Using Oracle Flashback Query (SELECT AS OF) To use Oracle Flashback Query, use a SELECT statement with an AS OF clause. Oracle Flashback Query retrieves data as it existed at an earlier time. The query explicitly references a past time through a time stamp or System Change Number (SCN). It returns committed data that was current at that point in time. Uses of Oracle Flashback Query include: • Recovering lost data or undoing incorrect, committed changes. For example, if you mistakenly delete or update rows, and then commit them, you can immediately undo the mistake. • Comparing current data with the corresponding data at an earlier time. For example, you can run a daily report that shows the change in data from yesterday. You can compare individual rows of table data or find intersections or unions of sets of rows.
  • 58. Date consideration in flashback Flashback Example: SQL> select * from countries where country_name='Iran'; no rows selected SQL> select to_char(sysdate,'rr/mm/dd hh24:mi:ss') as currdate from dual; CURRDATE ----------------- 17/02/15 15:27:07 SQL> insert into countries values('IR','Iran',4); 1 row created.
  • 59. Date consideration in flashback Flashback Example cont’d: SQL> select to_char(sysdate,'rr/mm/dd hh24:mi:ss') as currdate from dual; CURRDATE ----------------- 17/02/15 15:28:29 SQL> select * from countries where country_name='Iran'; CO COUNTRY_NAME REGION_ID -- ---------------------------------------- ---------- IR Iran 4
  • 60. Date consideration in flashback Flashback Example cont’d: SQL> select * from countries as of timestamp to_timestamp('17/02/15 15:27:07','rr/mm/dd hh24:mi:ss') where country_name='Iran'; no rows selected flashback table countries to timestamp to_timestamp('17/02/15 15:27:07','rr/mm/dd hh24:mi:ss'); Flashback succeeded. SQL> select * from countries where country_name='Iran'; no rows selected
  • 61. Date consideration in flashback Relative time: If you specify a relative time by subtracting from the current time on the database host, the past time is re calculated for each query. For example: SQL> insert into countries values ('PO','Poland',1); 1 row created. SQL> select * from countries As of timestamp (systimestamp - interval '1' minute) where country_name=' Poland'; CO COUNTRY_NAME REGION_ID -- ---------------------------------------- ---------- PO Poland 1
  • 62. Date consideration in flashback Arguments which could be passed to relevant flashback: select * from countries As of timestamp (systimestamp - interval '1' <argument>); Arguments Year Month Day Hour Minute Second
  • 63. Date consideration in flashback Relative or Exact ? Exact example: select * from countries As of timestamp to_timestamp('17/02/18 10:49:12', 'rr/mm/dd hh24:mi:ss'); Relative example: select * from countries As of timestamp (systimestamp - interval '1' minute); Method Simplicity Accuracy Exact No Yes Relative Yes No
  • 65. Question and Answer https://ir.linkedin.com/in/masoud-haji-hassan-pour Masoud Haji Hassan Pour mas.Hassanpour@gmail.com Thanks for your attention