Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table Field Names

Status
Not open for further replies.

Fiendy

Programmer
Sep 6, 2001
14
GB
Hi,

Does anyone know how to create a field name with a "#" or "%" character in it?
Eg.

CREATE TABLE test (`my fld#1` CHAR(1), `my fld%2` CHAR(1));

MySQL complains about this, despite the manual saying that these characters are allowed if enclosed in back-quotes (`).

I need to do this as I'm currently converting a Perl app to run against MySQL aswell as it's orignal DB (which has loads of fields with #'s in!).

Thanks,

Fiendy
 
The command ALTER TABLE `pjmmusic` ADD `xxx#` TINYINT UNSIGNED NOT NULL worked fine in the gui MSQL-Front. If you have problems it something else than mySql.

Best practice anyway would probably be to remove the # and %, there will be problems ...

I base that on the problems I have gotten with swedish national characters (å, ä and ö), they are said to be allowed but somehow it often dont work anyway.
 
Thanks for the reply.

I agree with you that it'd be best to remove the #'s etc, but unfortunatly I'm stuck with them as the original DB is used by a "Green Screen" application still, so I can't change it :-(

BTW: Your example "ALTER TABLE" statement definately doesn't work for me, although I'm using either the 'mysql' command line utility (Linux Mandrake & Red Hat), or Perl DBI.

The only way I can get around it is to convert the field names in the MySQL DB (Eg, # = __, so fld#1 would be fld__1), and then parse every SQL statement I issue & convert accordingly, which is a real pain!

Cheers anyway,

Fiendy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top