15 Maj 2008

Obróbka pliku z danymi


LOAD DATA INFILE 'D:\\dane_dane.txt' INTO TABLE dane

ALTER TABLE dane ADD KOLOR_N VARCHAR(255) AFTER ksiazka
ALTER TABLE dane_kolory ADD KOLOR_N VARCHAR(255) AFTER ksiazka
update dane set KOLOR_N = Replace (KOLOR, ' ', '')
create table kolory (KOLOR_N VARCHAR(255), cnt int(10));
insert into kolory (KOLOR_N, cnt) select KOLOR_N, count(*) from dane group by KOLOR_N
create table kolory_w1 (KOLOR_N VARCHAR(255), cnt int(10));
insert into kolory_w1 (KOLOR_N, cnt) select KOLOR_N, cnt from kolory WHERE kolory.cnt > 1
insert into dane_kolory select dane.* from kolory_w1 LEFT JOIN dane ON kolory_w1.KOLOR_N = dane.KOLOR_N

alter table dane add index KOLOR_N_idx (KOLOR_N)
alter table kolory_w1 add index KOLOR_N_idx (KOLOR_N)
select dane_kolory.* into outfile 'd:\\dane_dane2.txt' from dane_kolory;

15 Maj 2008

Wypełnianie bazy danymi z pliku, nowe, zmiany, usuniete

drop database mojedane2;
create database mojedane2;
use mojedane2;

create table nowe (klucz char(8), line text);
create table usuniete (klucz char(8), line text);
create table zmiany (klucz char(8), line text);

create table mojedane_old (klucz char(8), line text);
create table mojedane_new (klucz char(8), line text);

LOAD DATA INFILE 'D:\\mojedane\\05MAY.TXT' INTO TABLE mojedane_old
LOAD DATA INFILE 'D:\\mojedane\\05Jul.txt' INTO TABLE mojedane_new

insert into nowe (line) select mojedane_new.line from mojedane_new LEFT JOIN mojedane_old ON mojedane_new.klucz = mojedane_old.klucz WHERE mojedane_old.klucz is NULL;
select mojedane_new.line into outfile 'd:\\mojedane\\nowe.txt' from mojedane_new LEFT JOIN mojedane_old ON mojedane_new.klucz = mojedane_old.klucz WHERE mojedane_old.klucz is NULL;
insert into usuniete (line) select mojedane_old.line from mojedane_old LEFT JOIN mojedane_new ON mojedane_old.klucz = mojedane_new.klucz WHERE mojedane_new.klucz is NULL;
select mojedane_old.line into outfile 'd:\\mojedane\\usuniete.txt' from mojedane_old LEFT JOIN mojedane_new ON mojedane_old.klucz = mojedane_new.klucz WHERE mojedane_new.klucz is NULL;
insert into zmiany (line) select new.line from mojedane_new AS new, mojedane_old AS old where new.klucz = old.klucz AND new.line <> old.line
select new.line into outfile 'd:\\mojedane\\zmiany.txt' from mojedane_new AS new, mojedane_old AS old where new.klucz = old.klucz AND new.line <> old.line

15 Maj 2008

Parsowanie adresu w Access

Świdwin, ul. Kołobrzeska 3, tel. 094 3654041

poszukiwnie przecinków:
Mid(Mid([pole3];InStr([pole3];",")+2);InStr(Mid([pole3];InStr([pole3];","));",");InStr(Mid([pole3];InStr([pole3];",")+2);",")-1)