我正在尝试使用此函数创建名为ID1
的表:
public function createIDTable($IdNumber)
{
$sql = "CREATE TABLE `Database`.`ID$IdNumber` (`Names` LONGTEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL)";
$query = mysql_query($sql)or die (mysql_error());
return "Sucess";
}
它创建表,但名称始终为小写,如id1
。我需要ID1
- 我该怎么做?
答案 0 :(得分:1)
如果使用默认排序规则选项安装SQL Server,您可能会发现以下查询返回相同的结果:
CREATE TABLE mytable
(
mycolumn VARCHAR(10)
)
GO
SET NOCOUNT ON
INSERT mytable VALUES('Case')
GO
SELECT mycolumn FROM mytable WHERE mycolumn='Case'
SELECT mycolumn FROM mytable WHERE mycolumn='caSE'
SELECT mycolumn FROM mytable WHERE mycolumn='case'
您可以通过在列级别强制排序来更改查询:
SELECT myColumn FROM myTable
WHERE myColumn COLLATE Latin1_General_CS_AS = 'caSE'
SELECT myColumn FROM myTable
WHERE myColumn COLLATE Latin1_General_CS_AS = 'case'
SELECT myColumn FROM myTable
WHERE myColumn COLLATE Latin1_General_CS_AS = 'Case'
-- if myColumn has an index, you will likely benefit by adding
-- AND myColumn = 'case'
答案 1 :(得分:0)
请参阅http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_lower_case_table_names
如果您在具有不区分大小写的文件系统(Windows)的服务器上运行MySQL,请小心此设置。