SQL2005整理与Oracle [英] SQL2005 collation vs Oracle

查看:66
本文介绍了SQL2005整理与Oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


是否可以像Oracle一样设置SQL Server 2005的排序规则,即对象名称和列名称是否为
- 不敏感,但数据是敏感的b / b;例如:


在Oracle中:

- 创建小写表和列名字

创建表t1(c1 char(10));

- 使用大写J的麦克风

插入t1值(' 'Mike'');

- 我正在改变表名中的情况,但是它有效,但是

''Mike''必须与uppewr case M

从T1中选择*其中c1 =''Mike''


以上测试在SQL server中失败。有没有一个整理可以使数据

''文字''敏感,但数据字典或对象名称和列

名称不区分大小写?


TIA,

纳西尔

Hi there,

Is it posible to set the collation of SQL server 2005 like Oracle, which is
that objects names and column names are case-insensitive, but data is
sensitive;e.g:

In Oracle:
--create lower-case table and column name
create table t1(c1 char(10));
--Mike with upper-case J
insert into t1 values(''Mike'');
--follwoing I''m changing case in the table name, but it works, however
''Mike'' has to be with uppewr case M
select * from T1 where c1=''Mike''

Above test fails in SQL server. Is there a collation which can make data
''literals'' sensitive, but data dictionary or the object names and column
names case insensitive?

TIA,
Nasir

推荐答案

Nasir写道:
你好,

是否可以设置SQL Server 2005的整理,就像Oracle一样,对象名称和列名称不区分大小写,但数据是
在Oracle中:
- 创建小写表和列名
创建表t1(c1 char(10));
- 使用大写字母J
插入t1值(''Mike'');
- 我正在改变表名中的大小写但是它有效,但是
''迈克'必须与uppewr案件M
选择*来自T1其中c1 =''迈克'

上述测试在SQL服务器中失败。是否存在可以使数据文字敏感的排序规则,但数据字典或对象名称和列名称不区分大小写?

TIA,
纳西尔
Hi there,

Is it posible to set the collation of SQL server 2005 like Oracle, which is
that objects names and column names are case-insensitive, but data is
sensitive;e.g:

In Oracle:
--create lower-case table and column name
create table t1(c1 char(10));
--Mike with upper-case J
insert into t1 values(''Mike'');
--follwoing I''m changing case in the table name, but it works, however
''Mike'' has to be with uppewr case M
select * from T1 where c1=''Mike''

Above test fails in SQL server. Is there a collation which can make data
''literals'' sensitive, but data dictionary or the object names and column
names case insensitive?

TIA,
Nasir




是的。实际上,数据的整理总是在列

级别确定。数据库排序规则定义标识符是否为区分大小写的
,也是列排序规则的默认值。请看一下

查看联机丛书中的排序主题。


CREATE TABLE t1(c1 CHAR(10)COLLATE Latin1_General_CS_AS NOT NULL / *

.... * /);

INSERT INTO t1 VALUES(''Mike'');

INSERT INTO t1 VALUES(''mike'' );


SELECT * FROM T1 WHERE c1 =''Mike'';


结果:


c1

----------

Mike


(1排受影响)


-

David Portas,SQL Server MVP


请尽可能发布足够的代码来重现你的问题。

包含CREATE TABLE和INSERT语句通常会有所帮助。

说明您正在使用的SQL Server版本并指定内容

错误消息。


SQL Server联机丛书:
http://msdn2.microsoft.com/library/m...S,SQL.90).a spx

-



Yes. In fact the collation for data is always determined at column
level. The database collation defines whether identifiers are
case-sensitive and is also the default for the column collation. Take a
look at the collations topics in Books Online.

CREATE TABLE t1(c1 CHAR(10) COLLATE Latin1_General_CS_AS NOT NULL /*
.... */);
INSERT INTO t1 VALUES(''Mike'');
INSERT INTO t1 VALUES(''mike'');

SELECT * FROM T1 WHERE c1=''Mike'';

Result:

c1
----------
Mike

(1 row(s) affected)

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--


David,


我安装了使用SQL_Latin1_General_CP1_CS_AS的2005服务器希望

实现你所描述的内容,但看看会发生什么:


3>创建表t1(c1 char(10))

4> go

2> NSERT INTO t1 VALUES(''mike'')

3> go

(1行受影响)

1>插入t1值(''mike'')

2> go

(1行受影响)


1> SELECT * FROM T1 WHERE c1 =''Mike''

2> go

消息208,等级16,状态1,无效的对象名称''T1''。

1>

2> SELECT * FROM t1 WHERE c1 =''Mike''

3> go

c1

----------

Mike


( 1行受影响)

1>


我想知道你提到的整理是否可以在

服务器级别使用Latin1_General_CS_AS?


谢谢,

Nasir

" David Portas" < RE **************************** @ acm.org>在消息中写道

news:11 ********************** @ q12g2000cwa.googlegr oups.com ...
David,

I installed 2005 server with SQL_Latin1_General_CP1_CS_AS in hope to
acheive what you described, but look what happens:

3> create table t1 (c1 char(10))
4> go
2> NSERT INTO t1 VALUES(''mike'')
3> go
(1 rows affected)
1> INSERT INTO t1 VALUES(''mike'')
2> go
(1 rows affected)

1> SELECT * FROM T1 WHERE c1=''Mike''
2> go
Msg 208, Level 16, State 1, Invalid object name ''T1''.
1>
2> SELECT * FROM t1 WHERE c1=''Mike''
3> go
c1
----------
Mike

(1 rows affected)
1>

I wonder if collation you mentioned Latin1_General_CS_AS is available at
server level?

Thanks,
Nasir
"David Portas" <RE****************************@acm.org> wrote in message
news:11**********************@q12g2000cwa.googlegr oups.com...
Nasir写道:
你好,

是否可以像Oracle一样设置SQL Server 2005的整理,

对象名称和列名称不区分大小写,但数据敏感;例如:

在Oracle中:
- 创建小写表和列名称创建表t1(c1 char(10));
- 使用大写字母J
插入t1值(''Mike'');
- 告诉我''在表名中更改案例,但是它有效,但是''迈克'必须与uppewr案例M
从T1中选择*其中c1 =''迈克''
<在SQL Server中,上面的测试失败了。是否存在可以使数据文字敏感的排序规则,但数据字典或对象名称和列名称不区分大小写?

TIA,
纳西尔
Hi there,

Is it posible to set the collation of SQL server 2005 like Oracle, which
is
that objects names and column names are case-insensitive, but data is
sensitive;e.g:

In Oracle:
--create lower-case table and column name
create table t1(c1 char(10));
--Mike with upper-case J
insert into t1 values(''Mike'');
--follwoing I''m changing case in the table name, but it works, however
''Mike'' has to be with uppewr case M
select * from T1 where c1=''Mike''

Above test fails in SQL server. Is there a collation which can make data
''literals'' sensitive, but data dictionary or the object names and column
names case insensitive?

TIA,
Nasir



是的。实际上,数据的整理总是在列
级别确定。数据库排序规则定义标识符是否区分大小写,也是列排序规则的默认值。看看联机丛书中的排序主题。

CREATE TABLE t1(c1 CHAR(10)COLLATE Latin1_General_CS_AS NOT NULL / *
... * /); <插入进入t1值(''Mike'');
插入t1值(''mike'');

SELECT * FROM T1 WHERE c1 =''Mike' ';

结果:

c1
----------
迈克

(1受影响的行)

- 大卫Portas,SQL Server MVP

请尽可能发布足够的代码来重现您的问题。
包括CREATE TABLE和INSERT语句通常会有所帮助。
说明您正在使用的SQL Server版本并指定任何错误消息的内容。

SQL Server联机丛书: http://msdn2.microsoft。 com / library / m ... S,SQL.90).aspx
-



Yes. In fact the collation for data is always determined at column
level. The database collation defines whether identifiers are
case-sensitive and is also the default for the column collation. Take a
look at the collations topics in Books Online.

CREATE TABLE t1(c1 CHAR(10) COLLATE Latin1_General_CS_AS NOT NULL /*
... */);
INSERT INTO t1 VALUES(''Mike'');
INSERT INTO t1 VALUES(''mike'');

SELECT * FROM T1 WHERE c1=''Mike'';

Result:

c1
----------
Mike

(1 row(s) affected)

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--



Nasir写道:
大卫,

我用SQL_Latin1_General_CP1_CS_AS安装了2005服务器,希望能够实现您所描述的内容,但看看会发生什么:
David,

I installed 2005 server with SQL_Latin1_General_CP1_CS_AS in hope to
acheive what you described, but look what happens:




这是正确的。 CS是指CS。整理名称的一部分意味着

区分大小写。因此,如果您不需要区分大小写的标识,则需要将其更改为不敏感。您仍然可以为列指定CS归类



ALTER DATABASE垃圾COLLATE Latin1_General_CI_AS;


CREATE表t1(c1 CHAR(10)COLLATE Latin1_General_CS_AS NOT NULL / *

.... * /);

INSERT INTO t1 VALUES(''Mike'');

INSERT INTO t1 VALUES(''mike'');


SELECT * FROM T1 WHERE c1 =''Mike'';


以SQL_开头的排序规则存在向后兼容性

原因。除非与

版本7.0兼容,否则首选Windows排序规则。


-

David Portas,SQL Server MVP


只要有可能,请发布足够的代码来重现您的问题。

包含CREATE TABLE和INSERT语句通常会有所帮助。

说明什么版本您正在使用的SQL Server并指定任何错误消息的内容



SQL Server联机丛书:
http://msdn2.microsoft.com/library/m .. .S,SQL.90).aspx

-



That is correct. The "CS" part of the collation name means
Case-Sensitive. So you need to change it to Insensitive if you don''t
require case-sensitive identifers. You can still specify a CS collation
for the column:

ALTER DATABASE junk COLLATE Latin1_General_CI_AS ;

CREATE TABLE t1(c1 CHAR(10) COLLATE Latin1_General_CS_AS NOT NULL /*
.... */);
INSERT INTO t1 VALUES(''Mike'');
INSERT INTO t1 VALUES(''mike'');

SELECT * FROM T1 WHERE c1=''Mike'';

The collations beginning with SQL_ exist for backwards-compatibility
reasons. The Windows collations are preferred unless compatibility with
version 7.0 is required.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--


这篇关于SQL2005整理与Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆