Creating a daily backup MySQL database in Windows
"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump.exe" --host=localhost -uroot -ppassword --opt mydatabase > "C:\helmy\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup.sql"
It will create a file 2008_04_04_backup.sql
PL/SQL resources from SQL Kantin
Provide you some of the PL/SQL example i have experienced
Friday, April 04, 2008
Thursday, March 06, 2008
Getting Yesterdays or Tomorrows day with shell date command
$ date --date='2 year ago' # past
$ date --date='3 years' # go into future
$ date --date='2 days' # future
$ date --date='1 month ago' # past
$ date --date='2 months' # future
Sunday, March 02, 2008
Tuesday, January 29, 2008
Another way of manipulating large amount of data in oracle (Remove duplicate)
Below example explains, 1 way to remove duplicate data. tmp_data table contains 6millions of record, but with duplicate. Table tmp_duplicate contains all duplicates data that exists in tmp_data.
create or replace procedure delete_duplicate is
cursor c is select sn from tmp_data a where a.sn in (select sn from tmp_duplicate);
type c1_type is table of c%rowtype;
l_c1 c1_type;
begin
open c;
loop
fetch c bulk collect into l_c1 LIMIT 1000;
for i in 1 .. l_c1.count
loop
--Expecting to do the delete
dbms_output.put_line('Delete this ' || l_c1(i).sn);
end loop;
dbms_output.put_line('----------------------');
exit when c%notfound;
end loop;
close c;
end delete_duplicate;
Seperate certain data in file to another file.
Let say, i have many raw files, example data files generated from system. Every day the system generates the raw files, with pipe | seperated. At the end of the month i want to extract certain data from each of the files. Another problem arise is, these files contains more 100K of lines.
List of files in my unix server
mixed_raw_data_20080101.csv
mixed_raw_data_20080102.csv
mixed_raw_data_20080103.csv
mixed_raw_data_20080104.csv
mixed_raw_data_20080105.csv
mixed_raw_data_20080106.csv
.....
Content of the file
Hello|amy
Hello|amy
Hello|amy
Hello|amy
Hello|aby
Hello|aby
e.g:
Extract aby from all the listed files. Manually i can do each files like this
more mixed_raw_data_20080101.csv | grep '|aby' > mixed_raw_data_20080101.csv.extract
But what if i have to extract for the whole month which has 30 files....
for f in mixed_raw_data_*.csv; do more $f | grep '|aby' > $f.extract ; done;
Saturday, January 12, 2008
Sunday, December 09, 2007
Ps command with full string in unix?
# ps -ef | grep pr_next
root 4510 1 0 14:16:36 pts/1 0:23 /usr/java/bin/java -classpath /data1/DEVENV/APP/NEXT_INTERFACE/PROGRAM/pr_next_
root 4767 3157 0 15:43:52 pts/2 0:00 grep pr_next
but i need the full path of the command
# /usr/ucb/ps -auxxxwww | grep pr_next | more
root 4510 0.1 1.225023295680 pts/1 S 14:16:36 0:23 /usr/java/bin/java -classpath /data1/DEVENV/APP/NEXT_INTERFACE/PROGRAM/pr_next_sp_inv/etc:/data
1/DEVENV/APP/NEXT_INTERFACE/PROGRAM/pr_next_sp_inv/lib/pr_next_sp_inv.jar com.next.prepaid.sp.inventory.RemoteServer
root 4769 0.0 0.0 1224 888 pts/2 S 15:45:20 0:00 grep pr_next
Tuesday, November 13, 2007
update and select in oracle
UPDATE INCOMING_LEAD
SET (INCOMING_LEAD.DEPARTMENT_CD, INCOMING_LEAD.PROGRAM_CD,
INCOMING_LEAD.EFFORT_CD, INCOMING_LEAD.OFFER_CD) =
(SELECT OFFER_INPUT_KEYCODE.DEPARTMENT_CD,
OFFER_INPUT_KEYCODE.PROGRAM_CD, OFFER_INPUT_KEYCODE.EFFORT_CD,
OFFER_INPUT_KEYCODE.OFFER_CD
FROM OFFER_INPUT_KEYCODE
WHERE OFFER_INPUT_KEYCODE.INPUT_KEYCODE =
INCOMING_LEAD.PROMO_INITIAL_KEYCODE)
Subscribe to:
Posts (Atom)