Chinaunix首页 | 论坛 | 博客
  • 博客访问: 91745991
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Oracle

2008-04-30 19:13:19




   SELECT empseq.currval FROM DUAL ;
   自动插入序列的数值
   INSERT INTO emp
        VALUES (empseq.nextval, 'LEWIS', 'CLERK',
                7902, SYSDATE, 1200, NULL, 20) ;

   <2>. ROWNUM
    按设定排序的行的序号
    SELECT * FROM emp WHERE ROWNUM < 10 ;

   <3>. ROWID
    返回行的物理地址
    SELECT ROWID, ename FROM emp  WHERE deptno = 20 ;

33、对CLOB字段进行全文检索
SELECT * FROM A WHERE dbms_lob.instr(a.a,'K',1,1)>0;

34. 特殊字符的插入,比如"&"
insert into a values (translate ('at{&}t','at{}','at'));

35.表管理
 <1>.create a table
 sql> create table table_name (column datatype,column datatype]....)
 sql> tablespace tablespace_name [pctfree integer] [pctused integer]
 sql> [initrans integer] [maxtrans integer]
 sql> storage(initial 200k next 200k pctincrease 0 maxextents 50)
 sql> [loggingnologging] [cachenocache]

 <2>.copy an existing table
 sql> create table table_name [loggingnologging] as subquery
 
 <3> create table ... as 方式建表的时候,指定表参数
    create table a
      storage(
              initial 1M   /*第一次创建时分配空间*/
              next 1M      /*第一次分配的空间用完时在分配*/
              )
              as  select * from b;
 <4>.创建临时表
 sql> create global temporary table xay_temp as select * from xay;
  on commit preserve rows/on commit delete rows
 在Oracle中,可以创建以下两种临时表:
   a 会话特有的临时表:
 create global temporary table () on commit preserve rows;
 会话指定,当中断会话时ORACLE将截断表

   b 事务特有的临时表:
 create global temporary table () on commit delete rows;
 事务指定,每次提交后ORACLE将截断表(删除全部行)
   c 说明
    临时表只在当前连接内有效
  临时表不建立索引,所以如果数据量比较大或进行多次查询时,不推荐使用
  数据处理比较复杂的时候时表快,反之视图快点
  在仅仅查询数据的时候建议用游标: open cursor for 'sql clause';
 <5>
    pctfree = (average row size - initial row size) *100 /average row size
    pctused = 100-pctfree- (average row size*100/available data space)
 <6>.change storage and block utilization parameter
 sql> alter table table_name pctfree=30 pctused=50 storage(next 500k
 sql> minextents 2 maxextents 100);

阅读(408) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~