分类: Mysql/postgreSQL
2010-03-03 18:03:16
/*
Set table default charset, if not set
SYNOPSIS
set_table_default_charset()
create_info Table create information
DESCRIPTION
If the table character set was not given explicitely,
let’s fetch the database default character set and
apply it to the table.
*/
static void set_table_default_charset(THD *thd,
HA_CREATE_INFO *create_info, char *db)
{
/*
If the table character set was not given explicitly,
let’s fetch the database default character set and
apply it to the table.
*/
if (!create_info->default_table_charset)
{
HA_CREATE_INFO db_info;
load_db_opt_by_name(thd, db, &db_info);
create_info->default_table_charset= db_info.default_table_charset;
}
}
另外要说明的是,如果你是通过alter databases(schema) 命令更改的数据库默认属性,那么现有的表的默认字符集和排序规则不受影响。
通过创建数据库指定数据库的默认字符集和排序规则:
create_specification:
[DEFAULT] CHARACTER SET [=] charset_name
| [DEFAULT] COLLATE [=] collation_name
也可以通过alter database修改
alter_specification:
[DEFAULT] CHARACTER SET [=] charset_name
| [DEFAULT] COLLATE [=] collation_name