Skip to main content

Posts

Showing posts with the label Database

Oracle Tips

Here are some helpful tips to remember when dealing with oracle. I. Use the “flashback technology” when you accidentally commit a mistake with your production data. (altering entire table contents, corrupted table data, or worst dropping unintended table). - First thing to do is to enable flashback on your database. ALTER DATABASE FLASHBACK ON; - Restoring database to its good state. FLASHBACK DATABASE TO RESTORE POINT bef_damage; - Restoring dropped table. FLASHBACK TABLE [TABLE_NAME] TO BEFORE DROP; - Restoring table to its good state. FLASHBACK TABLE [TABLE_NAME] TO TIMESTAMP TO_TIMESTAMP('[DATE_TIME]'); II. Manipulate date and time display Aside from to_date and to_timestamp functions , you could also alter the date and time display in your database through the use of this code below. ALTER SESSION SET NLS_DATE_FORMAT = '[DATE_FORMAT]'

Oracle Split , Join , and DateDiff Functions

Split, Join and DateDiff are just few Oracle functions that can aid you in data manipulation. Function Definition Split - split a result by “character specified (by default, comma)” into multiple results. e.g. “A,B,C” –> results 3 records of “A”,”B”, and “C”. Join - join multiple records into one result by “character specified (by default, comma)”. e.g. “1″,”2″,”3″ –> results 1 record of “1,2,3″. DateDiff - Differentiate two dates. Function Code create or replace function split( p_list varchar2, p_del varchar2 := ',' ) return split_tbl pipelined is l_idx pls_integer; l_list varchar2(32767) := p_list; l_value varchar2(32767); begin loop l_idx := instr(l_list,p_del); ...