咖啡仔

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

随笔分类 -  oracle

摘要:使用以下语句创建了一个全局的临时表,在提交后就会清空数据。1 create global temporary table temp_t on commit preserve rows as select * from a在使用1 execute immediate 'insert into temp_t select * from a;如果使用了 commit;数据就会清空了,我就曾因这样使用过,导致后面执行的数据老是没成功。 阅读全文
posted @ 2011-12-31 17:09 咖啡仔 阅读(462) 评论(0) 推荐(0)

摘要:select sum(round(to_number(sysdate-to_date('2011-12-21 12:12:00','yyyy-mm-dd hh24:mi:ss'))*24*60)) from dual;如果想要其他格式的再扩展就行了。 阅读全文
posted @ 2011-12-21 12:00 咖啡仔 阅读(169) 评论(0) 推荐(0)

摘要:软件环境:1、操作系统:win xp2、数据库:oracle 10.23、安装路径:d:\oracle4、测试class目录:d:\test前提:如果是使用外部调用java程序的,确保oracle安装目录下的jdk和你编译的jdk版本一致。要不会报找不到class异常的。同时也确保把class文件放至数据库服务器硬盘中。实现方法:1、创建一java文件:OraclejavaProc.javaView Code 1 public class OraclejavaProc {2 public static void main(String[] args) {3 System... 阅读全文
posted @ 2011-12-19 17:11 咖啡仔 阅读(1090) 评论(0) 推荐(0)

摘要:Insert 和Update的吗,Merge的语法如下:View Code 1 MERGE INTO table_name alias1 2 USING (table|view|sub_query) alias23 ON (join condition) 4 WHEN MATCHED THEN 5 UPDATE table_name 6 SET col1 = col_val1, 7 col2 = col2_val 8 WHEN NOT MATCHED THEN 9 INSERT (column_list) VALUES (column_value... 阅读全文
posted @ 2011-12-15 13:19 咖啡仔 阅读(199) 评论(0) 推荐(0)

摘要:View Code 1 create database link dblink connect to username identified by password using 'service_name '; 之后就可以创建的数据库中使用select * from a@dlink去访问另一数据库的表,a是另一数据库的表 阅读全文
posted @ 2011-12-15 13:13 咖啡仔 阅读(169) 评论(0) 推荐(0)

摘要:View Code 1 declare 2 type a_type is table of number; 3 -- type a_type is array(10) of number; 4 -- 下面一种定义方式则指定了该数组的最大元素个数 5 6 a a_type := a_type(); -- 定义并初始化一个数组变量 7 begin 8 a.extend(3); -- 数组扩展到3个元素 ... 阅读全文
posted @ 2011-12-15 12:43 咖啡仔 阅读(537) 评论(0) 推荐(0)

摘要:View Code 1 Oracle数组一般可以分为固定数组和可变数组 2 固定数组 3 4 declare 5 type v_ar is varray(10) of varchar2(30); 6 my_ar v_ar:=v_ar('g','m','d','龚','帅'); 7 begin 8 for i in 1..my_ar.count 9 loop 10 dbms_output.put_line(my_ar(i)); 11 end loop; 12 end; ... 阅读全文
posted @ 2011-12-15 12:42 咖啡仔 阅读(474) 评论(0) 推荐(0)

摘要:Oralce在begin 和end 之间创建数据表时,会出现如标题的错误。 语句如下:begin create table create table temp_status as select * from into_status end; 按下F8进行执行语句会出现如下错误 错误:PLS-00103: 出现符号 "CREATE"在需要下列之一时:begin case declare exit for goto if loop mod null pragma raise return select update while with <an iden... 阅读全文
posted @ 2011-12-15 12:34 咖啡仔 阅读(4276) 评论(0) 推荐(1)

摘要:我在存储过程动态执行创建表的方法时 beginexecute immediate 'create table temp_a as select * from b';end;编译时出现 ora-01031:权限不足 解决方法: create or replace procedure sp_java_temp authid current_user as ……增加authid current_user 赋以当前使用用户的权限。 阅读全文
posted @ 2011-12-15 11:32 咖啡仔 阅读(456) 评论(0) 推荐(0)

摘要:1 grant role on table to user; 其中role 可以有select,update,insert,delete,all等选择 table是授权某一张数据表 user 给授权的用户 阅读全文
posted @ 2011-12-15 11:27 咖啡仔 阅读(297) 评论(0) 推荐(0)