个人面试题(Oracle数据库开发)(二)

来源:互联网 发布:鸡尾酒会算法 编辑:程序博客网 时间:2024/05/16 11:55

   个人面试题

 2015-09-15(下午)

1、什么时候用索引 具体量(oracle 应该有推荐)

2、什么时候用分区表 具体量(oracle 有推荐)

3、相同SQL查询 时快时慢,不知道是何问题

4、有null值走不走索引,或者索引有没有必要建?

5、数据库内存默认分配

6、append+nologging  优缺点  parallel (参数设置标准 oracle 应该有推荐)

7、分区表分区索引,局部索引、全局索引 



1、什么时候用索引 具体量(oracle 应该有推荐)

  不是Oracle 推荐。 别人的总结 附上链接:点击打开链接

        默认-表的主键、外键必须有索引;
  ①数据量超过300的表应该有索引;
  ②经常与其他表进行连接的表,在连接字段上应该建立索引;
  ③经常出现在Where子句中的字段,特别是大表的字段,应该建立索引;
  ④索引应该建在选择性高的字段上;
  ⑤索引应该建在小字段上,对于大的文本字段甚至超长字段,不要建索引;
  ⑥复合索引的建立需要进行仔细分析;尽量考虑用单字段索引代替:


2、什么时候用分区表 具体量(oracle 有推荐)

When to Partition a Table
分区使用情况
■ Tables greater than 2GB should always be considered for partitioning. 
■ Tables containing historical data, in which new data is added into the newest partition. 
A typical example is a historical table where only the current month's data is updatable and the other 11 months are read only.

分区数量限制
Oracle9iR2:
Tables can be partitioned into up to 64,000 separate partitions.
Oracle10gR2
Tables can be partitioned into up to 1024K-1 separate partitions.


3、相同SQL查询 时快时慢,不知道是何问题

未解。


4、有null值走不走索引,或者索引有没有必要建?

--有null值走索引,如果必须要设计 is null 的值可以选择组合索引(虚拟个 idx(comm,0)) 我试试
CREATE INDEX my_index ON scot.emp(comm,0);   --真特么可以
--或者使用函数索引去除null值
CREATE INDEX my_index ON my_table(DECODE(comm,0,0));

是否有必要建呢?

有比较创建

select * from emp a where a.comm>300; --是走索引的


5、数据库内存默认分配

sga 80%  pag 20%   OLTP



6、append+nologging  优缺点  parallel (参数设置标准 oracle 应该有推荐)

优点插入块(很少 redo buff)

缺点

1. append方式添加记录对insert into ... values语句不起作用。

2. 以append方式批量插入的记录,其存储位置在hwm 之上,即使hwm之下存在空闲块也不能使用。

3. 以append方式插入记录后,要执行commit,才能对表进行查询。否则会出现错误:


7、分区表分区索引,局部索引、全局索引 

--分区索引/*分区表会自动维护局部分区索引。全局索引会失效,需要进行rebuild。*/select index_name,table_name,partitioning_type from user_part_indexes ; /*分区索引分为 本地索引(local index)和全局索引 (global index)*/ --这个貌似是创建索引的同时分区create index i_id_global on tab_hash(id) globalpartition by list(id)(partition  part_01 , partition  part_02, partition  part_03);  --局部索引 local index create index ix_custaddr_local_id on tab_hash(id) local; select index_name,table_name,partitioning_type from user_part_indexes ; --全局索引 4.2 Global索引 /*对于分区索引,不能整体进行重建,只能对单个分区进行重建。语法如下:Alter index idx_name rebuild partition index_partition_name [online nologging]*/


0 0
原创粉丝点击