本站用于记录日常工作内容,虚拟化云计算,系统运维,数据库DBA,网络与安全。
oracle 使用PL/SQL与游标(CURSOR),循环(loop),条件(if)来更新数据。declare CURSOR emp_cursor is SELECT ename, sal FROM emp FOR UPDATE; emp_record emp_cursor%ROWTYPE;begin OPEN emp_cursor; LOOP FETCH emp_cursor INTO emp_record; EXIT WHEN emp_cursor%NOTFOUND; if emp_record.sal < 2000 THEN UPDATE emp SET sal = sal * 1.1 where CURRENT of emp_cursor; end if; end loop; commit;end;/本PL/SQL块使用了loop语句取的了所有雇员的姓名与工资,并且使用了条件控制语句(if)判断雇员工资,如果低于2000,则给该雇员增加10%的工资。使用sqldeveloper工具执行时,commit 只能放到end loop 之后,不能放到之前或是end if 之前。
oracle数据库时间戳转换成日期时间方法时间戳是自 1970 年 1 月 1 日(00:00:00 GMT)以来的秒数。它也被称为 Unix 时间戳(Unix Timestamp)。Unix时间戳(Unix timestamp),或称Unix时间(Unix time)、POSIX时间(POSIX time),是一种时间表示方式,定义为从格林威治时间1970年01月01日00时00分00秒起至现在的总秒数。Unix时间戳不仅被使用在Unix系统、类Unix系统中,也在许多其他操作系统中被广泛采用。北京时间是东8区,所以要加8小时。1, 现在需要将oracle数据库中的表中的时间戳字段转换成北京时间的日期时间格式,表格如下图。 COMPANY_NAME BILL_NUM STARTTIME 1 随州市甜蜜食品厂 9002254531 1370769194 使用下面方法可以转换。SELECT c.company_name,c.bill_num,c.starttime,TO_CHAR(c.starttime / (60 * 60 * 24) + TO_DATE('1970-01-01 08:00:00', 'YYYY-MM-DD HH:MI:SS'), &nbs...
oracle 利用存储过程输入参数返回多行数据方法。oracle 自带示例scott账号下,利用存储过程返回一行与多行数据方法。1,利用存储过程返回一行数据,输入参数empno,返回ename与sal.create or replace procedure p_emp_info(p_empno emp.empno%TYPE)asp_ename emp.ename%TYPE;p_sal emp.sal%TYPE;p_count NUMBER;begin select count(e.empno) into p_count from scott.emp e where e.empno=p_empno; if p_count=0 then return; end if; select ename,sal into p_ename,p_sal from emp e where e.empno=p_empno; DBMS_OUTPUT.put_line('部门号: '||p_empno||'.员工姓名:'||p_ename||'. 工资:'||p_sal);end;/由于select into 每次只能输入一行数据,所以这个方法只能用于一行数据返回。SQL> set serverout onSQL> exec p_emp_info(7782);部门号: 7782.员工姓名:CLARK. 工资:2450PL/SQL procedure successfully completed2,使用过程与游标,for in 循环,返回多行数据。SQL> create or replace procedure get_emp_info(p_deptno emp.deptno%T...
Warning: log write elapsed time 664ms, size 1KB 突然才发现一个数据库的LGWR进程的跟踪文件scm2_lgwr_5690.trc有大量的告警信息,如下所示: *** 2017-08-07 17:05:03.132Warning: log write elapsed time 664ms, size 1KBkcrfw_update_adaptive_sync_mode: post->poll long#=1 sync#=6 sync=302 poll=1079 rw=322 ack=0 min_sleep=1079*** 2017-08-07 17:42:56.997Log file sync switching to pollingCurrent scheduling delay is 1 usecCurrent approximate redo synch write rate is 2 per sec*** 2017-08-08 09:00:03.923Warning: log write elapsed time 1445ms, size 1KB*** 2017-08-08 10:00:20.162Warning: log write elapsed time 1190ms, size 87KB*** 2017-08-08 17:05:02.924Warning: log write elapsed time 1213ms, size 1KB*** 2017-08-09 08:36:15.179Warning: log write elapsed time 3171ms, size 1KBkcrfw_update_adaptive_sync_mode: poll->post current_sched_delay=0 switch_sched_delay=1 current_sync_count_delta=0 switch_sync_count_delta=6*** 2017-08-09 18:39:36.593Log file sync switching to post/waitCurrent ap...
Install Oracle Database 12c On CentOS7 In this tutorial, we will show you how to Install Oracle Database 12c On CentOS 7OS information:[root@ora-c7 ~]# cat /etc/centos-release
CentOS Linux release 7.0.1406 (Core)
Network:[root@ora-c7 ~]# ip a | grep inet
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
inet 192.168.119.139/24 brd 192.168.119.255 scope global dynamic eno16777736
inet6 fe80::20c:29ff:fe41:1494/64 scope link
Login as root and add required groups: /usr/sbin/groupadd -g 501 oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/groupadd -g 503 operAdd user Oracle:/usr/sbin/useradd -u 502 -g oinstall -G dba,oper oracleChange password for user:passwd oracleAdd kernel parameters to /etc/sysctl.conf. kernel.shmmni = 4096
kernel.shmmax = 4398046511104
kernel.shmall = 1073741824
kernel.sem = 250 32000 100 128
fs.aio...
Active Session History (ASH) performed an emergency flush 告警日志信息 Tue Sep 15 14:29:27 2015 Active Session History (ASH) performed an emergency flush. This may mean that ASH is undersized. If emergency flushes are a recurring issue, you may consider increasing ASH size by setting the value of _ASH_SIZE to a sufficiently large value. Currently, ASH size is 67108864 bytes. Both ASH size and the total number of emergency flushes since instance startup can be monitored by running the following query: select total_size,awr_flush_emergency_count from v$ash_info; 执行告警日志中查询语句 SYS@hkprdbuat> select total_size/1024/1024 MB,awr_flush_emergency_count from v$ash_info; MB AWR_FLUSH_EMERGENCY_COUNT ---------- ------------------------- 64 3 查询当前大小 select x.ksppinm name,y.ksppstvl value,y.ksppstdf isdefault,decode(bitand(y.ksppstvf,7),1,'MODIFIED',4,'SYSTEM_MOD','FALSE') ismod, decode(bitand(y.ksppstvf,2),2,'TRUE','FALSE') isadj from sys.x$ksp...
最近一台新上线的Oracle 数据库在警告日志文件中(alert.log)持续出现如下错误:Tue Jul 18 23:09:22 2006WARNING: inbound connection timed out (ORA-3136)Tue Jul 18 23:09:23 2006WARNING: inbound connection timed out (ORA-3136)Tue Jul 18 23:09:25 2006WARNING: inbound connection timed out (ORA-3136)Tue Jul 18 23:09:30 2006WARNING: inbound connection timed out (ORA-3136)Tue Jul 18 23:12:15 2006WARNING: inbound connection timed out (ORA-3136)同时在sqlnet.log中记录了如下错误:VERSION INFORMATION:TNS for Linux: Version 10.2.0.2.0 - ProductionOracle Bequeath NT Protocol Adapter for Linux: Version 10.2.0.2.0 - ProductionTCP/IP NT Protocol Adapter for Linux: Version 10.2.0.2.0 - ProductionTime: 19-JUL-2006 11:25:26Tracing not turned on.Tns error struct:ns main err code: 12535TNS-12535: TNS:operation timed outns secondary err code: 12606nt main err code: 0nt secondary err code: 0nt OS err code: 0Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.123)(PORT=58147))这是和网络连接相关的一个错误,Metalink上...
Microsoft SQL Server 数据库的 JDBC URL 格式对于 Microsoft SQL Server 数据库,可以使用以下示例 JDBC URL 作为模型:■ 按主机名连接到默认的(未命名的)SQL Server 实例:jdbc:sqlserver://host;databaseName=database■ 按主机名和实例名连接到已命名的实例:jdbc:sqlserver://host;instanceName=instance;databaseName=database■ 按主机名和端口连接到 SQL Server:jdbc:sqlserver://host:port;databaseName=database■ 按端口连接:jdbc:sqlserver://localhost:1422;databaseName\=VIM_VCDB(要单独传递的用户名、密码和数据库类型)■ 使用集成安全性连接到本地服务器:jdbc:sqlserver://localhost\\SQLEXP_VIM;databaseName=VIM_VCDB;integratedSecurity=true■ 不使用集成安全性连接到本地服务器:jdbc:sqlserver://localhost\\SQLEXP_VIM;databaseName\=VIM_VCDB (要单独传递的用户名、密码和数据库类型)默认情况下,Microsoft SQL Server 的 VMware vCenter Server JDBC 配置可能无法使用直接 IPv6 地址。必须使用下列形式之一:■ &nb...
服务器每隔一段时间后就出现无法登陆的问题。重启数据库后,问题解决,但这并不是长久之计。查看日志文件:D:\app\administrator\diag\rdbms\hzdb\hzdb\alert的alert.log,出现大量的重复错误信息,如下所示:Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=172.16.206.83)(PORT=2067)) TNS-00505: 操作超时 nt secondary err code: 60 nt OS err code: 0 ns secondary err code: 12560 nt main err code: 505 TNS-12535: TNS: 操作超时 Tracing not turned on. Tns error struct:ns main err code: 12535 VERSION INFORMATION: TNS for 32-bit Windows: Version 11.1.0.7.0 - Production Oracle Bequeath NTProtocol Adapter for 32-bit Windows: Version 11.1.0.7.0 - Production Windows NT TCP/IP NT ProtocolAdapter for 32-bit Windows: Version 11.1.0.7.0 - Production Fatal NI connect error 12170.为什么会出现这样的情况呢?网上搜索后得知,在Oracle11G中,有这样两个参数SQLNET.INBOUND_CONNECT_TIMEOUT 和INBOUND_CONNECT_TIMEOUT_list...
Oracle在10g中引入了闪回区(flash recovery area)的概念,用以简化和完善备份,但是闪回区同样需要精心规划和设置,否则一样会遇到问题,从Oracle10gR2开始,Oracle还提供了一个新的视图V$FLASH_RECOVERY_AREA_USAGE,用以监控闪回区空间的耗用情况。本文简要介绍Oracle闪回区的警报和空间维护机制。每次RMAN在闪回区(flash recovery area)创建文件时,会同时更新可删除文件列表。当闪回区存在空间压力时,Oracle会自动从闪回区中删除废弃文件,当没有更多空间可以释放时,Oracle会给出空间压力警报。当空间使用达到100%,数据库将会因为无法归档等原因挂起。闪回区的大小由:db_recovery_file_dest_size 参数指定。路径由: db_recovery_file_dest 参赛指定。 SQL> show parameter db_recovery
NAME TYPE VALUE
------------------------------------ ----------- ----------------------------...
总共51页,当前第16页 | 页数: - 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
最新评论