Salı, Aralık 08, 2009

postgres plperl destegi

Ubuntuda postgresql-plperl-8.4 paketini yukle.

createlang plperl -U kullanici -d veritabani -W

shell komutuyle dili veritabanina yukle.


create function caps(text) returns text as $$
my $x=$_[0];
$x =~ tr/[a-z]/[A-Z/;
return $x;
$$ LANGUAGE plperl;

select caps('der der');
caps
----------
DER DERE
(1 row)

Pazartesi, Kasım 23, 2009

Veritabaninda metin depolama

Super bir hesap yontemi. Sol kulagi sag elle tutmus biraderler ama yine de okay. 2.5 MB veriyi 5.2 MB olarak saklayacak bir veritabani sistemi ne ise yarar benim icin. Hic bir ise yaramaz.

Neticede metin dosyalarini dosya sisteminde tutmak daha akillica anlasilan.
Peki CouchDB nasil hallediyor bu isi. BLOB olarak tuttuklarini biliyorum sadece. Bakalim.

Cuma, Kasım 20, 2009

Veri dizinini degistirmek icin

Bu yazi 8.2 icin.

Pazartesi, Ekim 05, 2009

Postgres degisken

\set degisken 'lalala'

Sadece \set mevcut degiskenleri listeler

select * from tablo where sutun=:degisken;

Tabloyu dosyaya aktar

Either:

SELECT * FROM table \g filename

to just output to the file 'filename', or:

select * from lineshoot \g |cat >> /solsolute/path/filename

to append to the file. Both in psql, or:

echo 'SELECT * FROM table' | psql database >> test.out

from your terminal

Perşembe, Temmuz 30, 2009

Oracle da dosyadan metin yukleme

Example 10-18 Loading LOB DATA with One LOB per LOBFILE

Control File Contents

LOAD DATA
INFILE 'sample.dat'
INTO TABLE person_table
FIELDS TERMINATED BY ','
(name CHAR(20),
1 ext_fname FILLER CHAR(40),
2 "RESUME" LOBFILE(ext_fname) TERMINATED BY EOF)

Datafile (sample.dat)

Johny Quest,jqresume.txt,
Speed Racer,'/private/sracer/srresume.txt',

Secondary Datafile (jqresume.txt)

Johny Quest
500 Oracle Parkway
...

Secondary Datafile (srresume.txt)

Speed Racer
400 Oracle Parkway
...


http://students.kiv.zcu.cz/doc/oracle/appdev.102/b14259/xdb25loa.htm

Burada da XML yukleme ile ilgili ornek var.

Salı, Temmuz 28, 2009

Postgresql XML alani

Create table test
(y int, data xml);

insert into test values (1, 'ffr');

select xpath ('/foo/text()', data) from test;
xpath
-------
{ffr}
(1 row)

Pazartesi, Temmuz 27, 2009

Metin arama destegi

Ornek bir sorgu:

select 'a fat cat'::tsvector @@ 'cat'::tsquery;

Diger sorgu sekilleri icin kaynaklar:
  1. http://www.postgresql.org/docs/8.3/static/functions-textsearch.html
  2. http://www.postgresql.org/docs/8.3/static/ddl-schemas.html