我有以下查询来创建表:
CREATE TABLE qrtz_simprop_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
STR_PROP_1 VARCHAR(512) NULL,
STR_PROP_2 VARCHAR(512) NULL,
STR_PROP_3 VARCHAR(512) NULL,
INT_PROP_1 INT NULL,
INT_PROP_2 INT NULL,
LONG_PROP_1 BIGINT NULL,
LONG_PROP_2 BIGINT NULL,
DEC_PROP_1 NUMERIC(13,4) NULL,
DEC_PROP_2 NUMERIC(13,4) NULL,
BOOL_PROP_1 BOOL NULL,
BOOL_PROP_2 BOOL NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)) ENGINE=InnoDB
default charset=<value of character_set_client>;
也就是说,如果character_set_client
的值为UTF8
,则默认字符集应为utf8
;如果character_set_client
为latin1
,则默认字符集应为是latin1
。
这对我来说非常重要,即使花费数小时我也无法破解。任何帮助将不胜感激。
答案 0 :(得分:1)
You'd have to do this with dynamic SQL. You can't use variables directly in a CREATE TABLE statement.
SET @sql = CONCAT('CREATE TABLE ... DEFAULT CHARSET=', @@character_set_client);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
However, I wonder why you're doing this. I would normally allow the table charset to default to the charset for the schema. It seems odd to use the client charset.