1

我正在尝试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- 我该怎么做?

4

2 回答 2

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' 
于 2011-10-17T17:38:22.350 回答
0

请参阅http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_lower_case_table_names

如果您在具有不区分大小写的文件系统 (Windows) 的服务器上运行 MySQL,请注意此设置。

于 2011-10-17T17:41:17.027 回答