Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Wildcard Problem

Re: Wildcard Problem

From: gazzag <gareth_at_jamms.org>
Date: 24 Oct 2006 02:48:20 -0700
Message-ID: <1161683300.626280.176460@e3g2000cwe.googlegroups.com>


harry_johnson_4_you_at_yahoo.com wrote:
> William,
>
> Asking me how char(7) could be two character clued me in. The
> application is inserting spaces after the values. So if my values are
> 44, then it's adding 5 spaces to the end and that what it is. When I
> ran the query
>

<------------------------ snip ---------------------->

> Thanks for yoru help.

No Harry. The application is not padding the CHAR field with spaces. This is the behaviour of a CHAR field. i.e. it is a fixed length field. Therefore, a field defined as CHAR(7) will *always* be seven characters in length, regardless of the size of the string you've inserted into it. VARCHAR2(7), on the other hand, is a variable length field with a *maximum* of seven characters and, as Daniel said, is much more efficient.

e.g:

SQL> create table tab1 (
  2 col1 varchar2(5),
  3 col2 char(5));

Table created.

SQL> insert into tab1
  2 values ('X','X');

1 row created.

SQL> commit;

Commit complete.

SQL> select length(col1), length(col2) from tab1;

LENGTH(COL1) LENGTH(COL2)
------------ ------------

           1 5

SQL> HTH -g Received on Tue Oct 24 2006 - 04:48:20 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US