| 1 |
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION'; |
| 2 |
USE test; |
| 3 |
DROP TABLE IF EXISTS t1; |
| 4 |
CREATE TABLE t1 |
| 5 |
( |
| 6 |
f1 CHAR UNICODE, |
| 7 |
f2 CHAR(0) UNICODE, |
| 8 |
f3 CHAR(10) UNICODE, |
| 9 |
f5 VARCHAR(0) UNICODE, |
| 10 |
f6 VARCHAR(255) UNICODE, |
| 11 |
f7 VARCHAR(260) UNICODE, |
| 12 |
f8 TEXT UNICODE, |
| 13 |
f9 TINYTEXT UNICODE, |
| 14 |
f10 MEDIUMTEXT UNICODE, |
| 15 |
f11 LONGTEXT UNICODE |
| 16 |
) ENGINE = MyISAM; |
| 17 |
Warnings: |
| 18 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 19 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 20 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 21 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 22 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 23 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 24 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 25 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 26 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 27 |
Warning 1287 'UNICODE' is deprecated and will be removed in a future release. Please use CHARACTER SET charset_name instead |
| 28 |
SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; |
| 29 |
SELECT * FROM information_schema.columns |
| 30 |
WHERE table_schema LIKE 'test%' |
| 31 |
ORDER BY table_schema, |
| 32 |
table_name COLLATE utf8_general_ci, |
| 33 |
ordinal_position; |
| 34 |
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT GENERATION_EXPRESSION SRS_ID |
| 35 |
def test t1 f1 1 NULL YES char 1 2 NULL NULL NULL ucs2 ucs2_general_ci char(1) select,insert,update,references NULL |
| 36 |
def test t1 f2 2 NULL YES char 0 0 NULL NULL NULL ucs2 ucs2_general_ci char(0) select,insert,update,references NULL |
| 37 |
def test t1 f3 3 NULL YES char 10 20 NULL NULL NULL ucs2 ucs2_general_ci char(10) select,insert,update,references NULL |
| 38 |
def test t1 f5 4 NULL YES varchar 0 0 NULL NULL NULL ucs2 ucs2_general_ci varchar(0) select,insert,update,references NULL |
| 39 |
def test t1 f6 5 NULL YES varchar 255 510 NULL NULL NULL ucs2 ucs2_general_ci varchar(255) select,insert,update,references NULL |
| 40 |
def test t1 f7 6 NULL YES varchar 260 520 NULL NULL NULL ucs2 ucs2_general_ci varchar(260) select,insert,update,references NULL |
| 41 |
def test t1 f8 7 NULL YES text 32767 65535 NULL NULL NULL ucs2 ucs2_general_ci text select,insert,update,references NULL |
| 42 |
def test t1 f9 8 NULL YES tinytext 127 255 NULL NULL NULL ucs2 ucs2_general_ci tinytext select,insert,update,references NULL |
| 43 |
def test t1 f10 9 NULL YES mediumtext 8388607 16777215 NULL NULL NULL ucs2 ucs2_general_ci mediumtext select,insert,update,references NULL |
| 44 |
def test t1 f11 10 NULL YES longtext 2147483647 4294967295 NULL NULL NULL ucs2 ucs2_general_ci longtext select,insert,update,references NULL |
| 45 |
########################################################################## |
| 46 |
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH |
| 47 |
########################################################################## |
| 48 |
SELECT DISTINCT |
| 49 |
CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML, |
| 50 |
DATA_TYPE, |
| 51 |
CHARACTER_SET_NAME, |
| 52 |
COLLATION_NAME |
| 53 |
FROM information_schema.columns |
| 54 |
WHERE table_schema LIKE 'test%' |
| 55 |
AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH = 1 |
| 56 |
ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML, DATA_TYPE; |
| 57 |
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME |
| 58 |
SELECT DISTINCT |
| 59 |
CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML, |
| 60 |
DATA_TYPE, |
| 61 |
CHARACTER_SET_NAME, |
| 62 |
COLLATION_NAME |
| 63 |
FROM information_schema.columns |
| 64 |
WHERE table_schema LIKE 'test%' |
| 65 |
AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH <> 1 |
| 66 |
ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML, DATA_TYPE; |
| 67 |
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME |
| 68 |
2.0000 char ucs2 ucs2_general_ci |
| 69 |
2.0000 longtext ucs2 ucs2_general_ci |
| 70 |
2.0000 mediumtext ucs2 ucs2_general_ci |
| 71 |
2.0000 text ucs2 ucs2_general_ci |
| 72 |
2.0000 varchar ucs2 ucs2_general_ci |
| 73 |
2.0079 tinytext ucs2 ucs2_general_ci |
| 74 |
SELECT DISTINCT |
| 75 |
CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML, |
| 76 |
DATA_TYPE, |
| 77 |
CHARACTER_SET_NAME, |
| 78 |
COLLATION_NAME |
| 79 |
FROM information_schema.columns |
| 80 |
WHERE table_schema LIKE 'test%' |
| 81 |
AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH IS NULL |
| 82 |
ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML, DATA_TYPE; |
| 83 |
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME |
| 84 |
NULL char ucs2 ucs2_general_ci |
| 85 |
NULL varchar ucs2 ucs2_general_ci |
| 86 |
--> CHAR(0) is allowed (see manual), and here both CHARACHTER_* values |
| 87 |
--> are 0, which is intended behavior, and the result of 0 / 0 IS NULL |
| 88 |
SELECT CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML, |
| 89 |
TABLE_SCHEMA, |
| 90 |
TABLE_NAME, |
| 91 |
COLUMN_NAME, |
| 92 |
DATA_TYPE, |
| 93 |
CHARACTER_MAXIMUM_LENGTH, |
| 94 |
CHARACTER_OCTET_LENGTH, |
| 95 |
CHARACTER_SET_NAME, |
| 96 |
COLLATION_NAME, |
| 97 |
COLUMN_TYPE |
| 98 |
FROM information_schema.columns |
| 99 |
WHERE table_schema LIKE 'test%' |
| 100 |
ORDER BY TABLE_SCHEMA, TABLE_NAME COLLATE utf8_general_ci, ORDINAL_POSITION; |
| 101 |
COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE |
| 102 |
2.0000 test t1 f1 char 1 2 ucs2 ucs2_general_ci char(1) |
| 103 |
NULL test t1 f2 char 0 0 ucs2 ucs2_general_ci char(0) |
| 104 |
2.0000 test t1 f3 char 10 20 ucs2 ucs2_general_ci char(10) |
| 105 |
NULL test t1 f5 varchar 0 0 ucs2 ucs2_general_ci varchar(0) |
| 106 |
2.0000 test t1 f6 varchar 255 510 ucs2 ucs2_general_ci varchar(255) |
| 107 |
2.0000 test t1 f7 varchar 260 520 ucs2 ucs2_general_ci varchar(260) |
| 108 |
2.0000 test t1 f8 text 32767 65535 ucs2 ucs2_general_ci text |
| 109 |
2.0079 test t1 f9 tinytext 127 255 ucs2 ucs2_general_ci tinytext |
| 110 |
2.0000 test t1 f10 mediumtext 8388607 16777215 ucs2 ucs2_general_ci mediumtext |
| 111 |
2.0000 test t1 f11 longtext 2147483647 4294967295 ucs2 ucs2_general_ci longtext |
| 112 |
SET sql_mode = default; |
| 113 |
DROP TABLE t1; |