ORACLE问题,每天10问(十二)

发表于:2007-06-07来源:作者:点击数: 标签:
111. 返回大于等于N的最小整数值? SELECT CEIL(N) FROM DUAL; 112. 返回小于等于N的最小整数值? SELECT FLOOR(N) FROM DUAL; 113. 返回当前月的最后一天? SELECT LAST_DAY(SYSDATE) FROM DUAL; 114. 如何不同用户间数据导入? IMP SYSTEM/MANAGER FILE=AA.DMP

111. 返回大于等于N的最小整数值?

  SELECT CEIL(N) FROM DUAL;

  112. 返回小于等于N的最小整数值?

  SELECT FLOOR(N) FROM DUAL;

  113. 返回当前月的最后一天?

  SELECT LAST_DAY(SYSDATE) FROM DUAL;

  114. 如何不同用户间数据导入?

  IMP SYSTEM/MANAGER FILE=AA.DMP FROMUSER=USER_OLD TOUSER=USER_NEW ROWS=Y INDEXES=Y ;

       115. 如何找数据库表的主键字段的名称?

  SQL>SELECT * FROM user_constraints WHERE CONSTRAINT_TYPE='P' and table_name='TABLE_NAME';

  116. 两个结果集互加的函数?

  SQL>SELECT * FROM BSEMPMS_OLD INTERSECT SELECT * FROM BSEMPMS_NEW;
  SQL>SELECT * FROM BSEMPMS_OLD UNION SELECT * FROM BSEMPMS_NEW;
  SQL>SELECT * FROM BSEMPMS_OLD UNION ALL SELECT * FROM BSEMPMS_NEW;

  117. 两个结果集互减的函数?
  SQL>SELECT * FROM BSEMPMS_OLD MINUS SELECT * FROM BSEMPMS_NEW;

  118. 如何配置Sequence?

  建sequence seq_custid
  create sequence seq_custid start 1 incrememt by 1;

  建表时:
create table cust
{ cust_id smallint not null,
...}
insert 时:
insert into table cust
values( seq_cust.nextval, ...)


  119>.日期的各部分的常用的的写法

  取时间点的年份的写法:

SELECT TO_CHAR(SYSDATE,'YYYY') FROM DUAL;

  120>.取时间点的月份的写法:

SELECT TO_CHAR(SYSDATE,'MM') FROM DUAL;


原文转自:http://www.ltesting.net