关于安装:
安装Oracle10g时,所输入的全局的SID名称为test(即数据库名,不能作为用户名来登录),密码为test(该密码对应的用户为system,sys等)。
装完后,若从网页上登录oracle,则输入url:http://localhost:1158/em
若无法显示页面,则说明test的监听器还没启动,去服务里面启动OracleDBConsoletest。
页面出来后,上面会显示"登录到数据库:test",登录的用户名为system,密码为test,连接身份为normal。
sqlplus是oracle自带的,而pl/sql developer是别人开发的。
若从sqlplus登录,则用户名为system,密码为test,主机字符串为test;如果用别的用户和主机登录也可以,前提是必须要注册服务名,用向导的方式配置服务名步骤如下:
a,从oracle菜单目录下的"配置和移植工具"/"Net Configuration Assistant"里面配置"本地NET服务名配置",输入的第一个服务名为全局的SID,也就是前面安装时指定的那个"test"(即数据库名,注:如果是别的主机,需要填写别人的数据库的SI ......
rom:http://www.psoug.org/reference/dbms_metadata.html
General Information
Source
{ORACLE_HOME}/rdbms/admin/dbmsmeta.sql
First Available
9.0.1
几个常用过程或函数:
GET_DDL
Fetch DDL for objects
dbms_metadata.get_ddl(
object_type IN VARCHAR2,
name IN VARCHAR2,
schema IN VARCHAR2 DEFAULT NULL,
version IN VARCHAR2 DEFAULT 'COMPATIBLE',
model IN VARCHAR2 DEFAULT 'ORACLE',
transform IN VARCHAR2 DEFAULT 'DDL')
RETURN CLOB;
Table
CREATE TABLE test
PCTFREE 0
TABLESPACE uwdata AS
SELECT table_name, tablespace_name
from user_tables;
SET LONG 10000
SELECT dbms_metadata.get_ddl('TABLE', 'TEST')
from dual;
View
CREATE OR REPLACE VIEW my_tables AS
select table_name, tablespace_name
from user_tables;
SELECT dbms_metadata.get_ddl('VIEW', 'MY_TABLES')
from dual;
Function
CREATE OR REPLACE FUNCTION whoami RETURN VARCHAR2 IS
BEGIN
R ......
定义:escape关键字经常用于使某些特殊字符,如通配符:'%','_'转义为它们原
来的字符的意义,被定义的转义字符通常使用'\',但是也可以使用其他的符号。
实例:
SQL> select * from t11 where name like '%_%';
NAME
----------
aa_a
aaa
SQL> select * from t11 where name like '%\_%' escape '\';
NAME
----------
aa_a
注意:如果是 '/' 作为检索字符, 必须 用 '/' 作为转义符, 正斜扛也一样.
select * from wan_test where psid like '%//%' escape '/' ......
Author: rainnyzhong
Date:2010-1-15
1. 症状描述:
FALB12从EXCEL IMPORT DATA到DB,预计事务会运行1个多小时,在开始操作后40分钟左右,ORACLE挂死,任何用户都不可以再登陆了。
2. 分析
(1) 下面是挂死时OS的资源状况:
09:37:54 up 73 days, 23:31, 1 user, load average: 0.11, 0.24, 0.18
194 processes: 191 sleeping, 3 running, 0 zombie, 0 stopped
CPU states: cpu user nice system irq softirq iowait idle
total 6.7% 0.0% 0.3% 0.3% 0.0% 1.9% 90.4%
Mem: 2186616k av, 2168780k used, 17836k free, 0k shrd, 154716k buff
& ......
The following items are available in the network listener configuration file (listener.ora).
* Listener Address Section
* SID_LIST_listener_name Static Service Section
* Control Parameters
The listener.ora file is located in $ORACLE_HOME/network/admin on UNIX and ORACLE_HOME\network\admin on Windows NT, or in the directory specified by the TNS_ADMIN environment variable or registry value.
1. Listener Address Section
The listener address section of the listener.ora file defines the protocol address(es) of the listener.
DESCRIPTION
Purpose: Defines listener protocol address(es)
Example:
listener_name=
(description=
(address=(protocol=ipc)(key=extproc0))
(address=(protocol=tcp)(host=sales-pc)(port=1521)))
ADDRESS
Purpose: Defines a listener protocol address. This parameter can be embedded under a ADDRESS_LIST or DESCRIPTION.
Example:
listener_name=
(description=
(address=(protocol=ipc)(key=extproc0))
(address ......
用户号码 登陆时间
1300000000 2010-01-01
1300000001 2010-01-01
1300000002 2010-01-02
1300000001 2010-01-02
1300000003 2010-01-03
1300000002 2010-01-03
1300000004 2010-01-04
1300000003 2010-01-04
1300000004 2010-01-02
1300000006 2011-01-04
1300000001 2011-01-04
剔除重复登陆的用户,只计算统计时间内用户的第一次登陆记录。然后每天累加用户数。
select b.statusdate,
sum(times) over(partition by trunc(b.statusdate, 'mm') order by b.statusdate)
from (select a.statusdate, count(1) times
from (select phone, trunc(min(statusdate), 'dd') statusdate
from test_table t
where t.statusdate >= to_date('20100101', 'yyyymmdd') --统计开始时间
and t.statusdate < to_date('20100201', 'yyyymmdd')
group by phone) a --取用户第一条记录时间
group by a.statusdate) b
由统计开始和结束时间控制数据源。trunc(b.statusdate, 'mm') 控制累加的范围,如果是月则表示按月累计,也就是每月的第 ......