ITPub博客

首页 > 数据库 > Oracle > 创建表时控制延迟段的创建行为

创建表时控制延迟段的创建行为

原创 Oracle 作者:xypincle 时间:2017-04-30 09:52:12 0 删除 编辑

  1. 1.注意,创建的表不能在sys账户下,否则会报错:
  2. SQL> create table f_regs(reg_id number,reg_name varchar2(20)) segment creation deferred;

  3. 此时创建的表不会立即分配段空间:
  4. SQL> select count(*) from user_segments where segment_name='F_REGS';

  5.   COUNT(*)
  6. ----------
  7.      0
  8.     
  9. SQL> select count(*) from user_extents where segment_name='F_REGS';

  10.   COUNT(*)
  11. ----------
  12.      0

  13. 只有在执行insert后才会开始创建段空间:
  14. SQL> insert into f_regs values(1,'ZSP');

  15. 1 row created.

  16. SQL>
  17. SQL> select count(*) from user_segments where segment_name='F_REGS';

  18.   COUNT(*)
  19. ----------
  20.      1

  21. SQL> select count(*) from user_extents where segment_name='F_REGS';

  22.   COUNT(*)
  23. ----------
  24.      1

  25. 2.创建表后立即分配段空间:
  26. SQL> drop table f_regs purge;

  27. Table dropped.
  28.     
  29. SQL> create table f_regs(reg_id number,reg_name varchar2(20)) segment creation immediate;

  30. Table created.

  31. SQL> select count(*) from user_segments where segment_name='F_REGS';

  32.   COUNT(*)
  33. ----------
  34.      1

  35. SQL> select count(*) from user_extents where segment_name='F_REGS';

  36.   COUNT(*)
  37. ----------
  38.      1

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28878983/viewspace-2138215/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: yum命令
下一篇: 查看logging的模式
请登录后发表评论 登录
全部评论

注册时间:2013-05-11

  • 博文量
    208
  • 访问量
    212338