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 Jonathan Eric Miller <je...@uchicago.edu> on 2005/04/21 16:15:43 UTC

Way to quote schema/table names?

Hi,

I'm attempting to create a table which is in a schema named "at." I think 
that the string "at" in some contexts is considered a reserved word, so, 
it's failing. Does anyone know if there is a way to get this to work? i.e. a 
way to quote the schema and table name or something?

     [java] create table at.Department (
     [java]    id integer not null generated always as identity,
     [java]    name varchar(255),
     [java]    number varchar(32),
     [java]    title varchar(255),
     [java]    primary key (id)
     [java] )
     [java] Apr 20, 2005 4:46:23 PM org.hibernate.tool.hbm2ddl.SchemaExport 
execute
     [java] SEVERE: Unsuccessful: create table at.Department (id integer not 
null generated always as identity, name varchar(255), number varchar(32), 
title varchar(255), primary key (id))
     [java] Apr 20, 2005 4:46:23 PM org.hibernate.tool.hbm2ddl.SchemaExport 
exec
     [java] SEVERE: Syntax error: Encountered "at" at line 1, column 14.

Jon



Re: Way to quote schema/table names?

Posted by Jonathan Eric Miller <je...@uchicago.edu>.
Thanks.

Jon

----- Original Message ----- 
From: "Jack Klebanoff" <kl...@sbcglobal.net>
To: "Derby Discussion" <de...@db.apache.org>
Sent: Thursday, April 21, 2005 12:32 PM
Subject: Re: Way to quote schema/table names?


> Jonathan Eric Miller wrote:
>
>> Hi,
>>
>> I'm attempting to create a table which is in a schema named "at." I think 
>> that the string "at" in some contexts is considered a reserved word, so, 
>> it's failing. Does anyone know if there is a way to get this to work? 
>> i.e. a way to quote the schema and table name or something?
>>
>>     [java] create table at.Department (
>>     [java]    id integer not null generated always as identity,
>>     [java]    name varchar(255),
>>     [java]    number varchar(32),
>>     [java]    title varchar(255),
>>     [java]    primary key (id)
>>     [java] )
>>     [java] Apr 20, 2005 4:46:23 PM 
>> org.hibernate.tool.hbm2ddl.SchemaExport execute
>>     [java] SEVERE: Unsuccessful: create table at.Department (id integer 
>> not null generated always as identity, name varchar(255), number 
>> varchar(32), title varchar(255), primary key (id))
>>     [java] Apr 20, 2005 4:46:23 PM 
>> org.hibernate.tool.hbm2ddl.SchemaExport exec
>>     [java] SEVERE: Syntax error: Encountered "at" at line 1, column 14.
>>
>> Jon
>>
>>
>>
> You can quote schema and table names using the standard SQL quoting 
> mechanism: double quotes, '"'. E.g.
>
> create schema "at";
> create table "at".Department( ...);
>
> Note that when you quote a name it becomes case sensitive. So, in the 
> example above
>  select * from "AT".Department;
> will not work, Derby will not find schema "AT", you must use "at" instead.
>
> Jack Klebanoff
> 


Re: Way to quote schema/table names?

Posted by Jack Klebanoff <kl...@sbcglobal.net>.
Jonathan Eric Miller wrote:

> Hi,
>
> I'm attempting to create a table which is in a schema named "at." I 
> think that the string "at" in some contexts is considered a reserved 
> word, so, it's failing. Does anyone know if there is a way to get this 
> to work? i.e. a way to quote the schema and table name or something?
>
>     [java] create table at.Department (
>     [java]    id integer not null generated always as identity,
>     [java]    name varchar(255),
>     [java]    number varchar(32),
>     [java]    title varchar(255),
>     [java]    primary key (id)
>     [java] )
>     [java] Apr 20, 2005 4:46:23 PM 
> org.hibernate.tool.hbm2ddl.SchemaExport execute
>     [java] SEVERE: Unsuccessful: create table at.Department (id 
> integer not null generated always as identity, name varchar(255), 
> number varchar(32), title varchar(255), primary key (id))
>     [java] Apr 20, 2005 4:46:23 PM 
> org.hibernate.tool.hbm2ddl.SchemaExport exec
>     [java] SEVERE: Syntax error: Encountered "at" at line 1, column 14.
>
> Jon
>
>
>
You can quote schema and table names using the standard SQL quoting 
mechanism: double quotes, '"'. E.g.

create schema "at";
create table "at".Department( ...);

Note that when you quote a name it becomes case sensitive. So, in the 
example above
  select * from "AT".Department;
will not work, Derby will not find schema "AT", you must use "at" instead.

Jack Klebanoff