|
|||||||||||
|
Re: DBD::mysql retrieving column collation
From: Paul DuBois <paul(at)mysql.com>
Date: Thu Jul 05 2007 - 20:18:01 EDT
In the C API, you can distinguish binary from non-binary strings by checking whether the charset_nr value is 63 (binary) or <> 63 (non-binary). However, I don't think that DBD::mysql exposes this member of the column metadata structures. If you resort to parsing SHOW output, you might find the output of SHOW COLUMNS easier to deal with, because it's in row-and-column format. SHOW FULL COLUMNS displays an additional Collation column, which is non-NULL for non-binary string columns. (For binary string data types such as BINARY or VARBINARY or BLOB, it's NULL.) Example: mysql> show create table t\G
*************************** 1. row ***************************
Table: t
Create Table: CREATE TABLE `t` ( `c1` char(10) DEFAULT NULL, `c2` char(10) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL, `c3` binary(10) DEFAULT NULL, `t` text, `b` blob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql> show full columns from t\G
*************************** 1. row ***************************
Field: c1
Type: char(10)
Collation: latin1_swedish_ci
Null: YES
Key:
Default: NULL
Extra:
Privileges: select,insert,update,references Comment:
*************************** 2. row ***************************
Field: c2
Type: char(10)
Collation: latin1_bin
Null: YES
Key:
Default: NULL
Extra:
Privileges: select,insert,update,references Comment:
*************************** 3. row ***************************
Field: c3
Type: binary(10)
Collation: NULL
Null: YES
Key:
Default: NULL
Extra:
Privileges: select,insert,update,references Comment:
*************************** 4. row ***************************
Field: t
Type: text
Collation: latin1_swedish_ci
Null: YES
Key:
Default: NULL
Extra:
Privileges: select,insert,update,references Comment:
*************************** 5. row ***************************
Field: b
Type: blob
Collation: NULL
Null: YES
Key:
Default: NULL
Extra:
Privileges: select,insert,update,references
Comment:
-- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL Perl Mailing List For list archives: http://lists.mysql.com/perl To unsubscribe: http://lists.mysql.com/perl?unsub=lists@pantek.comReceived on Thu Jul 5 20:18:24 2007 This archive was generated by hypermail 2.1.8 : Fri Jul 06 2007 - 21:25:58 EDT |
||||||||||
|
|||||||||||