I have seen other questions related to using special characters in column name but I didn't get my point. I want to use column name like
`first_name#abc|xyz|exy#`
Is it legal does it cause any security issue or any error while querying them?
MySQL 5.7 sets the encoding of the column names to utf-8 by default.
If you want to see the configuration in your system, execute the following command:
SHOW VARIABLES LIKE 'character_set_results';
Source: https://dev.mysql.com/doc/refman/5.7/en/charset-metadata.html
Related
I run a sqlite3 database with utf8-strings from many languages. For various reasons I want to move to mysql, but I constantly run into trouble because of the mysql-collation feature.
One problem is that I am not even able to reliably know what is in my database. (For example I get "?" for non-latin characters and "�" for latin-based characters like öé, etc. - but I have absolutely no idea whether the problem lies in the import from sqlite3 to mysql or in reading from the mysql-database.)
Is there a way to get rid of this "feature" and let mysql do what I tell it without trying to be smart? I use UTF-8 everywhere and I never need any mangling of strings: Input is always UTF-8 and output should be always UTF-8. Also I really would like to know what really is stored in the database - i.e. without a collation-feature corrupting the data during readout.
You could use the MySQL VARBINARY column type, which stores a sequence of arbitrary bytes without interpreting them in any particular charset (or maybe VARCHAR BINARY, which is subtly different).
MySQL uses latin1_swedish_ci unless you specify something different explicitly. That's the opposite of smart. You have to be smart and change that default. This can be done with e.g. the --character-set-server and --collation-server command line options. See Specifying Character Sets and Collations for other means and further options.
I have my mySQL collation set to utf8_general_ci and despite the fact that my searches are diacritical-insensitive, ie LIKE 'test' returns 'tést', some searches which I would like to work fail, in particular LIKE 'host' will NOT return 'høst'.
Two questions: Is there a table that will show which characters are equivalent for a particular collation? Is there a way to set two characters as equivalents in mySQL as an override?
Thanks for the help.
To answer for first question you can referance collation-charts.org. It's kind of a pain because you will need to search each collation by hand, but it'll show you how they stack.
The relevant section in the MySQL manual can also be found here.
As far as your second question, I'm not sure if you can do an explicit override for a particular character; however you can create your own custom character set if you wish.
You can read about creating custom collations from the MySQL manual.
I am using SQL server 2008 and have the column in my table set to nvarchar. Data with special characters are getting stored wrongly in this table. Eg: this is one entry
Need to check if doesn’t comes as doesn’t itself and don’t comes asdon’t itself and ensure closure of issues.
The garbage ’ should actually be an apostrophe ('). I have checked my collation string. At database level it is SQL_Latin1_General_CP850_BIN2 and at server level it is SQL_Latin1_General_CP1_CI_AS.
I know for sure the encoding set everywhere else in my application is UTF-8.
How do I store the data correctly in my table? Do I need to change my SQL queries or any settings in the database?
Please advise.
You need to make sure that you're observing two things:
Always use NVARCHAR as datatype for your columns
Always make sure to use the N'....' prefix when dealing with string literals (for example in your INSERT or UPDATE statements)
With those two things in place, SQL Server has no trouble at all storing all Unicode characters you might throw at it...
I want to find out which collation the mySQL database has. phpMyAdmin 2.8.0.3 doesn't show me that. Is there a command like mentioned in this thread? I would need it for the database, table, column and perhaps the string literal.
SHOW COLLATION appeared in mysql 4.1, actually, there wasn't much information about collations and character sets in 4.0. See the release notes for 4.1.0. My guess is that you can't get this information. I also think you can assume it's latin-1 as that was the default in 4.0.
SHOW CREATE TABLE table_name should include the character set and collation for the table.
To get the default for the database, try this:
show variables like 'character_set_database';
show variables like 'collation_database';
Not sure if these are available in your MySQL version however.
On my version 4.0.15 DB, I have been able to do:
SHOW VARIABLES LIKE "%char%";
And get:
i am interacting with the mysql database via perl. I was wondering if there are table name limits.
Also. How do i handle special characters within the table names when creating it through perl?
thanks
According to the MySQL docs, the maximum length for a table name is 64 characters. This page also describes the permissible syntax for identifiers.