chapter 5.1 Flashcards
how does oracle store dates internally
stores dates as numbers
date information is displayed as _______
DD-Mon-YYYY
what are the 2 types of data conversion
implicit data type
explicit data type
example of implicit data conversion
oracle server can automatically convert char data to NUMBER and DATE data types
what is 1 way to ensure reliability in sql statements
it is best to explicitly make data type conversions to ensure reliability in SQL statements
what is example of explicit data types
character data type to number datatype using TO_NUMBER function
Number data type to character data type using TO_CHAR
syntax for to_char when converting date to character data
TO_CHAR(date column name, ‘format model you specify’)
how do you spell out a number using format model
use sp
how to have the number appear as an ordinal using format model
use th
why use fm element
remove padded blanks or remove leading zeroes from the output
how to specify the numeric day of year
DDD
how to specify the numeric day of the month
DD
how to specify the numeric day of the week
D
how to specify the hours
HH
how to specify the minutes
MI
how to specify the seconds
SS
how to get 24 hour time with am/pm
HH24:MI:SS AM
sql format to convert number to character data
TO_CHAR(number, ‘format model ‘)
how do you want to format numbers in money format ($xx,xxx)
SELECT TO_CHAR(SALARY, ‘$99,999’) AS “SALARY”
FROM EMPLOYEE;
how do you perform character conversion to number
USE TO_NUMBER(CHARACTER STRING, ‘format model’)
the format model is optional but should be included if character string contains any characters other than numbers
what happens if in the TO_NUMBER function the column value has 4 values but the format model has only 3 characters
invalid number error
what function to convert a character string to a date format
to_date(‘character string’, ‘format model ‘)
what does the format model tells the server in the to_date function
tells the server what the character string looks like
what does the fx (format exact) modifier specify
specifies the exact matching for the character argument and the date format model