| From: | Neil Conway <neilc(at)samurai(dot)com> |
|---|---|
| To: | emilu(at)cs(dot)concordia(dot)ca |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Questions about "varchar" NOT NULL default = char(1) |
| Date: | 2005-09-15 20:42:52 |
| Message-ID: | 4329DCCC.7020303@samurai.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Emi Lu wrote:
> Greetings,
>
> If one column "col1" is defined as :
>
> col1 varchar(1) not null default ''
>
> Does it means that col1's definition is equal to
>
> col1 char(1) not null default ''
Not quite; for example,
neilc=# create table t1 (x char(1) not null);
CREATE TABLE
neilc=# create table t2 (x varchar(1) not null);
CREATE TABLE
neilc=# insert into t1 values ('');
INSERT 0 1
neilc=# insert into t2 values ('');
INSERT 0 1
neilc=# select octet_length(x) from t1;
octet_length
--------------
1
(1 row)
neilc=# select octet_length(x) from t2;
octet_length
--------------
0
(1 row)
> Put it another way, will char '' be saved as char(1) or char '' does not
> use space at all?
I'm not sure what you mean.
-Neil
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2005-09-15 21:07:46 | Re: character varying == text? |
| Previous Message | Chris Browne | 2005-09-15 20:37:07 | Re: Asychronous database replication |