主键列O9i的最佳数据类型 [英] optimum datatype for primary key column O9i

查看:147
本文介绍了主键列O9i的最佳数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于大多数

优化访问的主键列,使用什么是数据类型




- 那里将只是一个单列主键

- 值只是整数(但是

字符串)至少12位数(字符)长

- 所有职位都将被占用(没有领先0')


- 表可能有多达1m +行

- 会有很多foriegn重要参考

和亲子访问


请让我有任何建议


Sanjay Minni www.planage.com

What is the datatype to be used
for Primary Key columns for most
optimised access given that

- There will be a single column primary key only
- The values will only be integers (but as
strings) at least 12 digits (characters) long
- all positions will be occupied (no leading 0''s)

- Tables may have upto 1m+ rows
- There will be lot of foriegn key references
and master-child access

Please let me have any suggestions

Sanjay Minni
www.planage.com

推荐答案

你好


你可以使用varchar2 ......但是我建议你不用任何代码来代替这些密钥......使用这些密钥......使用这样的哑键


My_dumb_key My_key

1 A12

2 A2

现在让my_ dumb_key作为你的主要数字,是一个由

序列填充的数字......


我认为这是最好的。你可以让My_key独一无二..


阅读有关数据建模的书籍,他们会有详细的解释


问候

Hrishy
Hi

You can use varchar2...but i suggest you dont code any intelligence in
these keys...use dumb keys like this

My_dumb_key My_key
1 A12
2 A2
now make my_dumb_key as your primary which is a number populated by a
sequence or something..

I think this is the best.You can make My_key unique..

Read books on data modelling they will have detailed explanation

regards
Hrishy


我的意思是专门针对Oracle 8i / 9i,

内部数据存储方法和数据&索引结构

将使用的最佳数据类型

[12位密钥长度]以充分利用

空间[数据&安培;索引]和访问速度[加入等]。


效果将级联,因为大多数主键列

将被复制为其他的foriegn键桌子

并且总是会使用大型连接


Sanjay Minni
www.planage.com
What I meant was that specifically to Oracle 8i/9i,
internal data storage methods and data & index structures
what will be the optimum datatype to be used
[for 12 digit key lengths] to make best use
of space [data & index] and speed of access [joins etc].

The effect will cascade as most of the primary key columns
will be duplicated as foriegn keys in other tables
and invariably large joins will be used

Sanjay Minni
www.planage.com


sm ****************** @ planage.com (Sanjay Minni)在留言中写道新闻:< 4f ************************* @ posting.google.c om> ...
sm******************@planage.com (Sanjay Minni) wrote in message news:<4f*************************@posting.google.c om>...
什么我的意思是专门针对Oracle 8i / 9i,内部数据存储方法和数据&索引结构
什么是最佳数据类型
[12位数密钥长度]以充分利用空间[data& amp;访问速度[连接等]。

效果将级联,因为大多数主键列将被复制为其他表格中的foriegn键,并且总是很大将使用加入

Sanjay Minni
www.planage.com
What I meant was that specifically to Oracle 8i/9i,
internal data storage methods and data & index structures
what will be the optimum datatype to be used
[for 12 digit key lengths] to make best use
of space [data & index] and speed of access [joins etc].

The effect will cascade as most of the primary key columns
will be duplicated as foriegn keys in other tables
and invariably large joins will be used

Sanjay Minni
www.planage.com




如果您的密钥是数字,那么您可以做出的最愚蠢的举动之一就是将它们存储在varchar2中。
。数字列已打包,varchar2

列不是。如果有人错误地写了这样的查询,你很可能最终会进行隐式转换

问题

key_column = 1234.

这将是由Oracle自动转换为
to_number(key_column)= 1234

因此不会使用主键索引。


问候

Sybrand Bakker

高级Oracle DBA



If your key is numeric, one of the most stupid moves you can make is
storing them in varchar2s. Numeric columns are packed, varchar2
columns aren''t. Also you are likely to end up with implicit conversion
issues if someone mistakenly writes queries like this one
key_column = 1234.
This will be automatically converted by Oracle to
to_number(key_column) = 1234
and consequently the primary key index will not be used.

Regards
Sybrand Bakker
Senior Oracle DBA


这篇关于主键列O9i的最佳数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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