Connecting Tech Pros Worldwide Forums | Help | Site Map

case-insensitive database

Relaxin
Guest
 
Posts: n/a
#1: Nov 11 '05
Is there a way to make Postgresql case-INSENSITIVE?

Thanks



Christopher Browne
Guest
 
Posts: n/a
#2: Nov 11 '05

re: case-insensitive database


Quoth "Relaxin" <noname@spam.com>:[color=blue]
> Is there a way to make Postgresql case-INSENSITIVE?[/color]

It already is.

portfolio=# select * from stocks limit 1;
symbol | description | exchange
--------+-------------+----------
AADBX | AADBX | NYSE
(1 row)

portfolio=# sELeCT * FROM STOCKS LIMIT 1;
symbol | description | exchange
--------+-------------+----------
AADBX | AADBX | NYSE
(1 row)

Those queries were cased differently, but were recognized as being
functionally identical.
--
output = ("aa454" "@" "freenet.carleton.ca")
http://cbbrowne.com/info/linux.html
debugging, v:
Removing the needles from the haystack.
Christopher Browne
Guest
 
Posts: n/a
#3: Nov 11 '05

re: case-insensitive database


Quoth "Relaxin" <noname@spam.com>:[color=blue]
> Is there a way to make Postgresql case-INSENSITIVE?[/color]

It already is.

portfolio=# select * from stocks limit 1;
symbol | description | exchange
--------+-------------+----------
AADBX | AADBX | NYSE
(1 row)

portfolio=# sELeCT * FROM STOCKS LIMIT 1;
symbol | description | exchange
--------+-------------+----------
AADBX | AADBX | NYSE
(1 row)

Those queries were cased differently, but were recognized as being
functionally identical.
--
output = ("aa454" "@" "freenet.carleton.ca")
http://cbbrowne.com/info/linux.html
debugging, v:
Removing the needles from the haystack.
Relaxin
Guest
 
Posts: n/a
#4: Nov 11 '05

re: case-insensitive database


No, I mean the data.

select * from stocks where symbol = 'AADBX'
and
select * from stocks where symbol = 'aadbx'

would bring up the same result set.


"Christopher Browne" <cbbrowne@acm.org> wrote in message
news:m3u17gsxhe.fsf@chvatal.cbbrowne.com...[color=blue]
> Quoth "Relaxin" <noname@spam.com>:[color=green]
> > Is there a way to make Postgresql case-INSENSITIVE?[/color]
>
> It already is.
>
> portfolio=# select * from stocks limit 1;
> symbol | description | exchange
> --------+-------------+----------
> AADBX | AADBX | NYSE
> (1 row)
>
> portfolio=# sELeCT * FROM STOCKS LIMIT 1;
> symbol | description | exchange
> --------+-------------+----------
> AADBX | AADBX | NYSE
> (1 row)
>
> Those queries were cased differently, but were recognized as being
> functionally identical.
> --
> output = ("aa454" "@" "freenet.carleton.ca")
> http://cbbrowne.com/info/linux.html
> debugging, v:
> Removing the needles from the haystack.[/color]


Relaxin
Guest
 
Posts: n/a
#5: Nov 11 '05

re: case-insensitive database


No, I mean the data.

select * from stocks where symbol = 'AADBX'
and
select * from stocks where symbol = 'aadbx'

would bring up the same result set.


"Christopher Browne" <cbbrowne@acm.org> wrote in message
news:m3u17gsxhe.fsf@chvatal.cbbrowne.com...[color=blue]
> Quoth "Relaxin" <noname@spam.com>:[color=green]
> > Is there a way to make Postgresql case-INSENSITIVE?[/color]
>
> It already is.
>
> portfolio=# select * from stocks limit 1;
> symbol | description | exchange
> --------+-------------+----------
> AADBX | AADBX | NYSE
> (1 row)
>
> portfolio=# sELeCT * FROM STOCKS LIMIT 1;
> symbol | description | exchange
> --------+-------------+----------
> AADBX | AADBX | NYSE
> (1 row)
>
> Those queries were cased differently, but were recognized as being
> functionally identical.
> --
> output = ("aa454" "@" "freenet.carleton.ca")
> http://cbbrowne.com/info/linux.html
> debugging, v:
> Removing the needles from the haystack.[/color]


Dennis Gearon
Guest
 
Posts: n/a
#6: Nov 11 '05

re: case-insensitive database


Relaxin wrote:
[color=blue]
>No, I mean the data.
>
>select * from stocks where symbol = 'AADBX'
>and
>select * from stocks where symbol = 'aadbx'
>
>would bring up the same result set.
>
>
>[/color]
Look in the manuals, there are SQL functions like:

STRTOLOWER( ); STRTOUPPER() like those in 'C'

Usage:
-------
SELECT *
FROM stocks
WHERE
STRTOLOWER( symbol ) = STRTOLOWER( 'AADBX' );



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Relaxin
Guest
 
Posts: n/a
#7: Nov 11 '05

re: case-insensitive database


Hello....
Does anyone understand what is meant by a case-insensitive database.

Are there some collations that can be changed or is there just no way to
have a true case-insensitive Postgresql database?

Thanks

"Dennis Gearon" <gearond@fireserve.net> wrote in message
news:3F64CA36.5010202@fireserve.net...[color=blue]
> Relaxin wrote:
>[color=green]
> >No, I mean the data.
> >
> >select * from stocks where symbol = 'AADBX'
> >and
> >select * from stocks where symbol = 'aadbx'
> >
> >would bring up the same result set.
> >
> >
> >[/color]
> Look in the manuals, there are SQL functions like:
>
> STRTOLOWER( ); STRTOUPPER() like those in 'C'
>
> Usage:
> -------
> SELECT *
> FROM stocks
> WHERE
> STRTOLOWER( symbol ) = STRTOLOWER( 'AADBX' );
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>[/color]


Stephan Szabo
Guest
 
Posts: n/a
#8: Nov 11 '05

re: case-insensitive database



On Sat, 13 Sep 2003, Relaxin wrote:
[color=blue]
> Is there a way to make Postgresql case-INSENSITIVE?[/color]

Case insensitive in what regard?
That textual comparisons are done case-insensitively in queries?
That object names are determined case-insensitively?


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

darren@crystalballinc.com
Guest
 
Posts: n/a
#9: Nov 11 '05

re: case-insensitive database


select * from stocks where lower(symbol) = 'aadbx';
or
select * from stocks where symbol ilike =aadbx';
or
select * from stocks where symbol ~* 'aadbx';


HTH
Darren
On Sat, 13 Sep 2003, Relaxin wrote:
[color=blue]
> No, I mean the data.
>
> select * from stocks where symbol = 'AADBX'
> and
> select * from stocks where symbol = 'aadbx'
>
> would bring up the same result set.
>
>
> "Christopher Browne" <cbbrowne@acm.org> wrote in message
> news:m3u17gsxhe.fsf@chvatal.cbbrowne.com...[color=green]
> > Quoth "Relaxin" <noname@spam.com>:[color=darkred]
> > > Is there a way to make Postgresql case-INSENSITIVE?[/color]
> >
> > It already is.
> >
> > portfolio=# select * from stocks limit 1;
> > symbol | description | exchange
> > --------+-------------+----------
> > AADBX | AADBX | NYSE
> > (1 row)
> >
> > portfolio=# sELeCT * FROM STOCKS LIMIT 1;
> > symbol | description | exchange
> > --------+-------------+----------
> > AADBX | AADBX | NYSE
> > (1 row)
> >
> > Those queries were cased differently, but were recognized as being
> > functionally identical.
> > --
> > output = ("aa454" "@" "freenet.carleton.ca")
> > http://cbbrowne.com/info/linux.html
> > debugging, v:
> > Removing the needles from the haystack.[/color]
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>[/color]

--
Darren Ferguson


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Stephan Szabo
Guest
 
Posts: n/a
#10: Nov 11 '05

re: case-insensitive database



On Sat, 13 Sep 2003, Relaxin wrote:
[color=blue]
> No, I mean the data.
>
> select * from stocks where symbol = 'AADBX'
> and
> select * from stocks where symbol = 'aadbx'
>
> would bring up the same result set.[/color]

Potentially on some systems it'd be possible to
generate a case insensitive collation as part of a locale
and then use such for LC_COLLATE on initdb which would make all
comparisons of text fields case insensitive. That wouldn't
let you choose some case sensitive and case insensitive
right now (until we supported different collations within
one database). Others have already given most of the normal
query change ways already I believe (ilike, using upper or
lower, etc).

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Relaxin
Guest
 
Posts: n/a
#11: Nov 11 '05

re: case-insensitive database


Thank you, that was the answer I was look for.

"Stephan Szabo" <sszabo@megazone.bigpanda.com> wrote in message
news:20030914172223.W53960@megazone.bigpanda.com.. .[color=blue]
>
> On Sat, 13 Sep 2003, Relaxin wrote:
>[color=green]
> > No, I mean the data.
> >
> > select * from stocks where symbol = 'AADBX'
> > and
> > select * from stocks where symbol = 'aadbx'
> >
> > would bring up the same result set.[/color]
>
> Potentially on some systems it'd be possible to
> generate a case insensitive collation as part of a locale
> and then use such for LC_COLLATE on initdb which would make all
> comparisons of text fields case insensitive. That wouldn't
> let you choose some case sensitive and case insensitive
> right now (until we supported different collations within
> one database). Others have already given most of the normal
> query change ways already I believe (ilike, using upper or
> lower, etc).
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>[/color]


Tom Lane
Guest
 
Posts: n/a
#12: Nov 11 '05

re: case-insensitive database


Stephan Szabo <sszabo@megazone.bigpanda.com> writes:[color=blue]
> Potentially on some systems it'd be possible to
> generate a case insensitive collation as part of a locale
> and then use such for LC_COLLATE on initdb which would make all
> comparisons of text fields case insensitive.[/color]

Another possibility is to create a 'case insensitive text' datatype
that has its own case-insensitive comparison operators and associated
btree opclass. You would want to create an implicit cast to text and
an automatic cast from text so as to take advantage of the existing
text-type operations. I'm not sure whether this would work cleanly
or would result in can't-choose-the-operator-to-use errors, but it'd
be worth trying.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Dennis Gearon
Guest
 
Posts: n/a
#13: Nov 11 '05

re: case-insensitive database


Relaxin wrote:
[color=blue]
>Hello....
>Does anyone understand what is meant by a case-insensitive database.
>
>[/color]
You could define your own encoding, and use that.


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Closed Thread