Unix Technical Forum

CHARACTER SET

This is a discussion on CHARACTER SET within the MySQL General forum forums, part of the MySQL category; --> When you create a table, you can specify a character set for a column. How can you tell what ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 04:08 PM
Jerry Schwartz
 
Posts: n/a
Default CHARACTER SET

When you create a table, you can specify a character set for a column. How
can you tell what character set was used when the column was created?



Regards,



Jerry Schwartz

The Infoshop by Global Information Incorporated

195 Farmington Ave.

Farmington, CT 06032



860.674.8796 / FAX: 860.674.8341



<http://www.the-infoshop.com> www.the-infoshop.com

<http://www.giiexpress.com> www.giiexpress.com

www.etudes-marche.com


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 04:08 PM
Paul DuBois
 
Posts: n/a
Default Re: CHARACTER SET

>When you create a table, you can specify a character set for a column. How
>can you tell what character set was used when the column was created?


SHOW CREATE TABLE. If no character set is shown for the column,
it uses the table default character set.

Example:

mysql> create table t (c1 char(5) character set utf8, c2 char(5));
Query OK, 0 rows affected (0.16 sec)

mysql> show create table t\G
*************************** 1. row ***************************
Table: t
Create Table: CREATE TABLE `t` (
`c1` char(5) CHARACTER SET utf8 DEFAULT NULL,
`c2` char(5) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

The definition for c1 shows that utf8 is used

The definition for c2 shows nothing, so the table character set (latin1)
is used.

--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 04:09 PM
Jerry Schwartz
 
Posts: n/a
Default RE: CHARACTER SET

Bingo! You get a cookie.

Thanks, I knew there had to be a way.

Regards,

Jerry Schwartz
The Infoshop by Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341

www.the-infoshop.com
www.giiexpress.com
www.etudes-marche.com

>-----Original Message-----
>From: Paul DuBois [mailtoaul@mysql.com]
>Sent: Wednesday, April 16, 2008 10:25 AM
>To: Jerry Schwartz; 'Mysql'
>Subject: Re: CHARACTER SET
>
>>When you create a table, you can specify a character set for a column.

>How
>>can you tell what character set was used when the column was created?

>
>SHOW CREATE TABLE. If no character set is shown for the column,
>it uses the table default character set.
>
>Example:
>
>mysql> create table t (c1 char(5) character set utf8, c2 char(5));
>Query OK, 0 rows affected (0.16 sec)
>
>mysql> show create table t\G
>*************************** 1. row ***************************
> Table: t
>Create Table: CREATE TABLE `t` (
> `c1` char(5) CHARACTER SET utf8 DEFAULT NULL,
> `c2` char(5) DEFAULT NULL
>) ENGINE=MyISAM DEFAULT CHARSET=latin1
>1 row in set (0.00 sec)
>
>The definition for c1 shows that utf8 is used
>
>The definition for c2 shows nothing, so the table character set (latin1)
>is used.
>
>--
>Paul DuBois, MySQL Documentation Team
>Madison, Wisconsin, USA
>MySQL AB, www.mysql.com




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 04:09 PM
Rob Wultsch
 
Posts: n/a
Default Re: CHARACTER SET

On Wed, Apr 16, 2008 at 7:24 AM, Paul DuBois <paul@mysql.com> wrote:
>
> > When you create a table, you can specify a character set for a column. How
> > can you tell what character set was used when the column was created?
> >

>
> SHOW CREATE TABLE. If no character set is shown for the column,
> it uses the table default character set.
>
> Example:
>
> mysql> create table t (c1 char(5) character set utf8, c2 char(5));
> Query OK, 0 rows affected (0.16 sec)
>
> mysql> show create table t\G
> *************************** 1. row ***************************
> Table: t
> Create Table: CREATE TABLE `t` (
> `c1` char(5) CHARACTER SET utf8 DEFAULT NULL,
> `c2` char(5) DEFAULT NULL
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1
> 1 row in set (0.00 sec)
>
> The definition for c1 shows that utf8 is used
>
> The definition for c2 shows nothing, so the table character set (latin1)
> is used.
>
> --
> Paul DuBois, MySQL Documentation Team
> Madison, Wisconsin, USA
> MySQL AB, www.mysql.com


Is there any reason that the information_schema would not be the
preferred method of finding this information?
mysql> select table_collation from tables WHERE `table_name` =
'mytable' AND table_schema ='mydatabase'\G


--
Rob Wultsch
wultsch@gmail.com
wultsch (aim)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 04:09 PM
Jerry Schwartz
 
Posts: n/a
Default RE: CHARACTER SET

The production system is running 4.1.22. Does it supports schemas?

In any event, I'm not familiar with using them.

Regards,

Jerry Schwartz
The Infoshop by Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341

www.the-infoshop.com
www.giiexpress.com
www.etudes-marche.com

>-----Original Message-----
>From: Rob Wultsch [mailto:wultsch@gmail.com]
>Sent: Wednesday, April 16, 2008 11:50 AM
>To: Paul DuBois
>Cc: Jerry Schwartz; Mysql
>Subject: Re: CHARACTER SET
>
>On Wed, Apr 16, 2008 at 7:24 AM, Paul DuBois <paul@mysql.com> wrote:
>>
>> > When you create a table, you can specify a character set for a

>column. How
>> > can you tell what character set was used when the column was

>created?
>> >

>>
>> SHOW CREATE TABLE. If no character set is shown for the column,
>> it uses the table default character set.
>>
>> Example:
>>
>> mysql> create table t (c1 char(5) character set utf8, c2 char(5));
>> Query OK, 0 rows affected (0.16 sec)
>>
>> mysql> show create table t\G
>> *************************** 1. row ***************************
>> Table: t
>> Create Table: CREATE TABLE `t` (
>> `c1` char(5) CHARACTER SET utf8 DEFAULT NULL,
>> `c2` char(5) DEFAULT NULL
>> ) ENGINE=MyISAM DEFAULT CHARSET=latin1
>> 1 row in set (0.00 sec)
>>
>> The definition for c1 shows that utf8 is used
>>
>> The definition for c2 shows nothing, so the table character set

>(latin1)
>> is used.
>>
>> --
>> Paul DuBois, MySQL Documentation Team
>> Madison, Wisconsin, USA
>> MySQL AB, www.mysql.com

>
>Is there any reason that the information_schema would not be the
>preferred method of finding this information?
>mysql> select table_collation from tables WHERE `table_name` =
>'mytable' AND table_schema ='mydatabase'\G
>
>
>--
>Rob Wultsch
>wultsch@gmail.com
>wultsch (aim)




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-17-2008, 04:09 PM
Paul DuBois
 
Posts: n/a
Default Re: CHARACTER SET

At 8:49 AM -0700 4/16/08, Rob Wultsch wrote:
>On Wed, Apr 16, 2008 at 7:24 AM, Paul DuBois <paul@mysql.com> wrote:
>>
>> > When you create a table, you can specify a character set for a column. How
>> > can you tell what character set was used when the column was created?
>> >

>>
>> SHOW CREATE TABLE. If no character set is shown for the column,
>> it uses the table default character set.
>>
>> Example:
>>
>> mysql> create table t (c1 char(5) character set utf8, c2 char(5));
>> Query OK, 0 rows affected (0.16 sec)
>>
>> mysql> show create table t\G
>> *************************** 1. row ***************************
>> Table: t
>> Create Table: CREATE TABLE `t` (
>> `c1` char(5) CHARACTER SET utf8 DEFAULT NULL,
>> `c2` char(5) DEFAULT NULL
>> ) ENGINE=MyISAM DEFAULT CHARSET=latin1
>> 1 row in set (0.00 sec)
>>
>> The definition for c1 shows that utf8 is used
>>
>> The definition for c2 shows nothing, so the table character set (latin1)
>> is used.
>>
>> --
>> Paul DuBois, MySQL Documentation Team
>> Madison, Wisconsin, USA
>> MySQL AB, www.mysql.com

>
>Is there any reason that the information_schema would not be the
>preferred method of finding this information?
>mysql> select table_collation from tables WHERE `table_name` =
>'mytable' AND table_schema ='mydatabase'\G


You can do that, too, unless your version of MySQL is older than 5.0.

--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:17 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com