Oracle SQL Faq: Neosoft Technologies
Oracle SQL Faq: Neosoft Technologies
nd
NeoSoft Technologies
nd
What are the difference between DDL, DML and DCL commands?
DDL is Data Definition Language statements. Some examples:
TRUNCATE - remove all records from a table, including all spaces allocated for the records are
removed
How does one escape special characters when building SQL queries?
NeoSoft Technologies
nd
NeoSoft Technologies
nd
How does one get the time difference between two date columns?
Look at this example query:
select floor(((date1-date2)*24*60*60)/3600)
|| ' HOURS ' ||
floor((((date1-date2)*24*60*60) floor(((date1-date2)*24*60*60)/3600)*3600)/60)
|| ' MINUTES ' ||
round((((date1-date2)*24*60*60) floor(((date1-date2)*24*60*60)/3600)*3600 (floor((((date1-date2)*24*60*60) floor(((date1-date2)*24*60*60)/3600)*3600)/60)*60)))
|| ' SECS ' time_difference
from
...
If you don't want to go through the floor and ceiling math, try this method (contributed by Erik Wile):
select to_char(to_date('00:00:00','HH24:MI:SS') +
(date1 - date2), 'HH24:MI:SS') time_difference
from ...
Note that this query only uses the time portion of the date and ignores the date itself. It will thus never
return a value bigger than 23:59:59.
NeoSoft Technologies
nd
NOW
NOW_PLUS_30_SECS
-------------------- -------------------03-JUL-2002 16:47:23 03-JUL-2002 16:47:53
NeoSoft Technologies
nd
NeoSoft Technologies
nd
NeoSoft Technologies
nd
DEPT10,
DEPT20,
DEPT30,
DEPT40
JOB
DEPT10
DEPT20
DEPT30
DEPT40
--------- ---------- ---------- ---------- ---------ANALYST
6000
CLERK
1300
1900
950
MANAGER
2450
2975
2850
PRESIDENT
5000
SALESMAN
5600
tableX;
NeoSoft Technologies
nd
How can one dump/ examine the exact content of a database column?
SELECT DUMP(col1)
FROM tab1
WHERE cond1 = val1;
DUMP(COL1)
------------------------------------Typ=96 Len=4: 65,66,67,32
For this example the type is 96, indicating CHAR, and the last byte in the column is 32, which is the ASCII
code for a space. This tells us that this column is blank-padded.
NeoSoft Technologies
nd
10