You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Thomas Dudziak <to...@gmail.com> on 2005/12/26 15:14:37 UTC

Default value for (VAR)CHAR FOR BIT DATA columns ?

Hi there,

I'd like to specify a default value for a (VAR)CHAR FOR BIT DATA
columns when creating a table. Is this possible with Derby, even if
the default value contains unprintable (non-ascii) characters ?

regards,
Tom

Re: Default value for (VAR)CHAR FOR BIT DATA columns ?

Posted by Thomas Dudziak <to...@gmail.com>.
On 12/28/05, Daniel John Debrunner <dj...@debrunners.com> wrote:

> The value is hex, not ASCII characters. Two characters, each in the
> range 0-F represent a single byte.

Ah, cool. I thought you wanted to write 'CAFE' as in: cafe :-)

Tom

Re: Default value for (VAR)CHAR FOR BIT DATA columns ?

Posted by Daniel John Debrunner <dj...@debrunners.com>.
Thomas Dudziak wrote:

> On 12/27/05, Daniel John Debrunner <dj...@debrunners.com> wrote:
> 
> 
>>Yes. Use literals/constants that represent VARCHAR FOR BIT DATA.
>>
>>create table t ( b varchar(20) for bit data default X'CAFE')
>>
>>The default here would be 0xCAFE
> 
> 
> Yes, I thought it would be something like that (without the X though).
> But how do I specify characters in e.g. the range 0 - 32 ? Is there
> something like an escape syntax ? Or can I use Base64 or hex ?

The value is hex, not ASCII characters. Two characters, each in the
range 0-F represent a single byte.

X'07' is the byte value 0x07.

Dan.


Re: Default value for (VAR)CHAR FOR BIT DATA columns ?

Posted by Thomas Dudziak <to...@gmail.com>.
On 12/27/05, Daniel John Debrunner <dj...@debrunners.com> wrote:

> Yes. Use literals/constants that represent VARCHAR FOR BIT DATA.
>
> create table t ( b varchar(20) for bit data default X'CAFE')
>
> The default here would be 0xCAFE

Yes, I thought it would be something like that (without the X though).
But how do I specify characters in e.g. the range 0 - 32 ? Is there
something like an escape syntax ? Or can I use Base64 or hex ?

regards,
Tom

Re: Default value for (VAR)CHAR FOR BIT DATA columns ?

Posted by Daniel John Debrunner <dj...@debrunners.com>.
Thomas Dudziak wrote:

> Hi there,
> 
> I'd like to specify a default value for a (VAR)CHAR FOR BIT DATA
> columns when creating a table. Is this possible with Derby, even if
> the default value contains unprintable (non-ascii) characters ?

Yes. Use literals/constants that represent VARCHAR FOR BIT DATA.

create table t ( b varchar(20) for bit data default X'CAFE')

The default here would be 0xCAFE

I tried to find a link to constant/literal syntax in the ref manual but
I failed. I thought I'd seen where this syntax is documented.


Dan.