Create the table using single quotes around the strange name.

sqlite> create table x (boomer int, 'squid-nick' text);
sqlite> insert into x values (1,'asdlh');
sqlite> select * from x;
1|asdlh
sqlite> select squid-nick from x;
SQL error: no such column: nick
sqlite> select 'squid-nick' from x;
squid-nick
/*oops, I selected the string not a column name. */
sqlite> select x.'squid-nick' from x;  /*reference the table name before the
column*/
asdlh


As an aside: If you realize that the database name for a column doesn't have
to be the same as the user friendly name in your user interface, you don't
have to use keywords or special characters as column names.


On Mon, Jan 25, 2010 at 9:18 AM, Patrick Ben Koetter 
<p...@state-of-mind.de>wrote:

> Can I add a column name containing a dash "-" and if yes, how would I do
> that?
>
> I am asking because I fail to add a column name that contains a dash "-"
> and I
> don't know if I cause the problem (easy solution) or if its something else
> causing this to fail.
>
> Here's what I try:
>
>  sqlite> create table test(column-1 varchar(255));
>  SQL error: near "-": syntax error
>
> So far I have had a look at the SQLite documentation, but couldn't find
> anything that would tell me about 'reserved' characters or how I would
> escape
> a dash.
>
> Thanks,
>
> p...@rick
>
> --
> state of mind
> Digitale Kommunikation
>
> http://www.state-of-mind.de
>
> Franziskanerstraße 15      Telefon +49 89 3090 4664
> 81669 München              Telefax +49 89 3090 4666
>
> Amtsgericht München        Partnerschaftsregister PR 563
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
VerifEye Technologies Inc.
905-948-0015x245
7100 Warden Ave, Unit 3
Markham ON, L3R 8B5
Canada
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to