level 6
No protocol specified
Exception in thread "main"
解决方法 xhost +
2010年05月19日 06点05分
3
level 6
oerr是oracle在unix上的查找ora错误的小工具,极其方便。
命令格式为:
oerr ora 错误编号
例如要查看ora-01632的描述:
[oracle@shtdtest oracle]$ oerr ora 01632
01632, 00000, "max # extents (%s) reached in index %s.%s"
// *Cause: An index tried to extend past maxextents
// *Action: If maxextents is less than the system max, raise it. Otherwise,
// you must recreate with larger initial, next or pctincrease params.
[oracle@shtdtest oracle]$
2010年05月21日 02点05分
4
level 6
转载::
平台:WinXP SP2
数据库版本:10.2.0.1
一、不使用OMF创建数据库
1.创建数据库实例,实例名为abc(只是Windows平台需要,Unix平台不需要)
C:\WINDOWS>oradim -new -sid abc
Instance created.
2.为了sys用户可以连入数据库执行操作,先创建数据库的密码文件,密码文件的名称必须为PWDsid.ora
C:\WINDOWS>orapwd password=oracle file=F:\oracle\product\10.2.0\database\PWDabc.ora
3.创建下列目录,以存放数据文件和dump信息
#数据文件目录
F:\oracle\product\oradata\abc
#background dump目录
F:\oracle\product\admin\abc\bdump
#core dump目录
F:\oracle\product\admin\abc\cdump
#user dump目录
F:\oracle\product\admin\abc\udump
4.在listener.ora中添加下列信息,把此数据库注册在监听器中(可选)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = abc)
(ORACLE_HOME = f:\oracle\product\10.2.0)
(service=abc)
)
)
5.为了可以访问数据库,在tnsnames.ora添加下列信息
abc =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1521))
(CONNECT_DATA =
(SERVER = dedicated)
(SERVICE_NAME = abc)
)
)
6.建立pfile文件F:\oracle\product\10.2.0\database\initabc.ora,文件的内容如下:
background_dump_dest='f:\oracle\product/admin/abc/bdump'
compatible='10.2.0.1.0'
control_files='F:\oracle\product\oradata\abc\control01.ctl','F:\oracle\product\oradata\abc\control02.ctl'
core_dump_dest='f:\oracle\product/admin/abc/cdump'
db_block_size=8192
db_name='abc'
db_recovery_file_dest='f:\oracle\product/flash_recovery_area'
db_recovery_file_dest_size=2147483648
pga_aggregate_target=41943040
processes=150
remote_login_passwordfile='EXCLUSIVE'
sga_max_size=167772160
sga_target=125829120
undo_management='AUTO'
undo_tablespace='UND01'
user_dump_dest='f:\oracle\product/admin/abc/udump'
7.连入数据库,并创建spfile文件
C:\WINDOWS>set ORACLE_SID=abc
C:\WINDOWS>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Apr 20 21:17:42 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an SQL instance.
SQL>create spfile from pfile;
File created.
8.启动数据库到nomount
SQL>startup nomount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1247924 bytes
Variable Size 104858956 bytes
Database Buffers 54525952 bytes
Redo Buffers 7139328 bytes
9.执行creata database脚本
SQL>@F:\oracle\product\admin\abc\create\createdb.sql
2010年05月21日 02点05分
5
level 6
Database created.
#createdb.sql脚本的具体内容如下:
create database abc
maxlogfiles 5
maxlogmembers 5
maxloghistory 1
maxdatafiles 100
maxinstances 1
user sys identified by oracle
user system identified by oracle
logfile group 1 ('F:\oracle\product\oradata\abc\redo01.log') size 10m reuse,
group 2 ('F:\oracle\product\oradata\abc\redo02.log') size 10m reuse,
group 3 ('F:\oracle\product\oradata\abc\redo03.log') size 10m reuse
datafile 'F:\oracle\product\oradata\abc\system01.dbf' size 325m reuse
extent management local
sysaux datafile 'F:\oracle\product\oradata\abc\sysaux01.dbf' size 325m reuse
default temporary tablespace temp
tempfile 'F:\oracle\product\oradata\abc\temp01.dbf' size 20m reuse
undo tablespace undotbs1
datafile 'F:\oracle\product\oradata\abc\undo01.dbf' size 200m reuse
character set utf8
national character set al16utf16;
10.执行catalog.sql,创建数据库的数据字典视图
SQL>spool f:\catalog.log
SQL>@F:\oracle\product\10.2.0\RDBMS\ADMIN\catalog.sql
SQL>spool off
11.执行catproc.sql,创建执行PL/SQL程序所需的所有包
SQL>spool f:\catproc.log
SQL>@F:\oracle\product\10.2.0\RDBMS\ADMIN\catproc.sql
SQL>spool off
到此数据库abc创建完毕,可以正常使用了
注:
1.pfile文件中undo_tablespace中的名字必需与create database中的相同,否则会出现ORA-01092:ORACLE instance terminated.Disconnection forced的错误。
2.数据字典视图不是都由catalog.sql创建,部分由catproc.sql创建,如:dba_data_files
二、使用OMF创建数据库
从Oracle9i起,Oracle提出了OMF的概念,主要是简化了日常的管理操作,下面的实验演示了使用OMF时创建数据库的过程:
1.先删除刚刚建立的abc数据库
1.1启动数据库到mount
SQL>startup mount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1247924 bytes
Variable Size 134219084 bytes
Database Buffers 25165824 bytes
Redo Buffers 7139328 bytes
Database mounted.
1.2将数据库设置为restricted session模式
SQL>alter system enable restricted session;
System altered.
1.3使用drop database命令删除数据库,这个操作将删除所有的数据文件(不包括参数和密码文件)
SQL>drop database;
Database dropped.
2.修改pfile文件F:\oracle\product\10.2.0\database\initabc.ora,添加下列内容:
db_create_file_dest='F:\oracle\product\oradata\'
db_create_online_log_dest_1='F:\oracle\product\oradata\'
3.连入数据库,并启动数据库到nomount
SQL>startup nomount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1247924 bytes
2010年05月21日 02点05分
6
level 6
Variable Size 104858956 bytes
Database Buffers 54525952 bytes
Redo Buffers 7139328 bytes
4.根据刚刚修改的pfile文件创建spfile文件
SQL>create spfile from pfile;
File created.
5.执行creata database脚本
SQL>@F:\oracle\product\admin\abc\create\createdb.sql
Database created.
#createdb.sql脚本的具体内容如下(可以看出内容很简洁,所有的数据文件的具体信息都不用指定):
create database abc
user sys identified by oracle
user system identified by oracle
default temporary tablespace temp
undo tablespace undotbs1
character set utf8
national character set al16utf16;
6.查看数据库的各个文件的位置和名称
6.1在线日志文件
SQL>select group#,member from v$logfile;
GROUP# MEMBER
---------- ----------------------------------------------------------------------
1 F:\ORACLE\PRODUCT\ORADATA\ABC\ONLINELOG\O1_MF_1_40PN2T5C_.LOG
2 F:\ORACLE\PRODUCT\ORADATA\ABC\ONLINELOG\O1_MF_2_40PN312X_.LOG
6.2数据文件
SQL>select tablespace_name,file_name from dba_data_files;
TABLESPACE FILE_NAME
---------- -------------------------------------------------------------------------------
SYSTEM F:\ORACLE\PRODUCT\ORADATA\ABC\DATAFILE\O1_MF_SYSTEM_40PN388S_.DBF
UNDOTBS1 F:\ORACLE\PRODUCT\ORADATA\ABC\DATAFILE\O1_MF_UNDOTBS1_40PN3OLK_.DBF
SYSAUX F:\ORACLE\PRODUCT\ORADATA\ABC\DATAFILE\O1_MF_SYSAUX_40PN3Q00_.DBF
6.3临时文件
SQL>select tablespace_name,file_name from dba_temp_files;
TABLESPACE FILE_NAME
---------- ---------------------------------------------------------------------
TEMP F:\ORACLE\PRODUCT\ORADATA\ABC\DATAFILE\O1_MF_TEMP_40PN3YJ3_.TMP
到此数据库abc创建完毕,可以正常使用了
三、附录:
create database的全部语法:
CREATE DATABASE database
USER SYS IDENTIFIED BY password
USER SYSTEM IDENTIFIED BY password
CONTROLFILE REUSE
MAXDATAFILES integer
MAXINSTANCES integer
MAXLOGFILES integer
MAXLOGMEMBERS integer
MAXLOGHISTORY integer
CHARACTER SET charset
NATIONAL CHARACTER SET charset
SET DEFAULT BIGFILE(SMALLFILE) TABLESPACE
LOGFILE GROUP integer file_specification
ARCHIVELOG(NOARCHIVELOG)
FORCE LOGGING
DATAFILE file_specification
SYSAUX DATAFILE file_specification
DEFAULT TABLESPACE tablespace DATAFILE datafile_tempfile_spec extent_management_clause
BIGFILE(SMALLFILE) DEFAULT TEMPORARY TABLESPACE tablespace TEMPFILE file_specification extent_management_clause
BIGFILE(SMALLFILE) UNDO TABLESPACE tablespace DATAFILE file_specification
SET TIME_ZONE = '+/–hh : mi'(time_zone_region)
2010年05月21日 02点05分
7
level 6
select table_name from dictionary where table_name like '%dba%';
没有内容,因为 ' ' 中区分大小写。
2010年05月21日 05点05分
8
level 6
dba_segments
Columns
___________________________
OWNER
Username of the segment owner
SEGMENT_NAME
Name,if any,of the segment
PARTITION_NAME
Partition/Subpartition Name,if any,of the segment
SEGMENT_TYPE
"Type of segment: "TABLE","CLUSTER","INDEX","ROLLBACK","DEFERRED
TABLESPACE_NAME
Name of the tablespace containing the segment
HEADER_FILE
ID of the file containing the segment header
HEADER_BLOCK
ID of the block containing the segment header
BYTES
Size,in bytes of the segment
BLOCKS
Size,in Oracle blocks of the segment
EXTENTS
Number of extents allocated to the segment
INITIAL_EXTENT
Size,in bytes,of the initial extent of the segment
NEXT_EXTENT
Size,in bytes,of the next extent to be allocated to the segment
MIN_EXTENTS
Minimum number of extents allowed in the segment
MAX_EXTENTS
Maximum number of extents allowed in the segment
PCT_INCREASE
Percent by which to increase the size of the next extent to be allocated
FREELISTS
Number of process freelists allocated in this segment
FREELIST_GROUPS
Number of freelist groups allocated in this segment
RELATIVE_FNO
Relative number of the file containing the segment header
BUFFER_POOL
The default buffer pool to be used for segments blocks
2010年05月25日 06点05分
9
level 6
dba_free_space
Free extents in all tablespaces
Columns
___________________________
TABLESPACE_NAME
Name of the tablespace containing the extent
FILE_ID
ID number of the file containing the extent
BLOCK_ID
Starting block number of the extent
BYTES
Size of the extent in bytes
BLOCKS
Size of the extent in ORACLE blocks
RELATIVE_FNO
Relative number of the file containing the extent
Example
--Free space in each tablespace:
COLUMN tablespace_name FORMAT A15
COLUMN "Total Free (MB) " FORMAT 999,999,999,999
COLUMN "Largest Free Extent (MB) " FORMAT 999,999,999,999
Select tablespace_name,
Sum(bytes/(1024*1024)) "Total Free (MB) ",
Max(bytes/(1024*1024)) "Largest Free Extent (MB) "
From dba_free_space
Group By tablespace_name;
Related:
SQL Script - Tablespace Free Space
2010年05月25日 07点05分
11
level 0
kthr memory page faults cpu
----- ----------- ------------------------ ------------ -----------
r b avm fre re pi po fr sr cy in sy cs us sy id wa
1 4 947285 4175 0 0 0 168 379 0 497 5799 657 8 1 76 14
3 0 947291 4169 0 0 0 0 0 0 1122 6334 2612 83 4 3 10
2 0 947131 4328 0 0 0 0 0 0 984 4623 2050 45 2 42 11
1 0 947132 4327 0 0 0 0 0 0 639 5963 644 33 2 63 2
1 0 947133 4326 0 0 0 0 0 0 481 4208 362 33 1 66 0
1 0 947133 4326 0 0 0 0 0 0 519 3168 413 24 1 73 2
1 0 947196 4262 0 0 0 0 0 0 486 7479 371 24 1 72 3
1 0 947196 4262 0 0 0 0 0 0 511 3321 476 15 2 81 3
0 0 947159 4299 0 0 0 0 0 0 536 3306 449 16 1 82 1
1 0 946402 5056 0 0 0 0 0 0 1397 4069 3845 30 3 35 32
1 1 946213 5245 0 0 0 0 0 0 772 2976 1113 8 2 84 5
0 0 946213 5245 0 0 0 0 0 0 657 3876 688 6 0 92 2
0 0 946213 5245 0 0 0 0 0 0 510 2566 408 4 0 95 0
2010年07月12日 01点07分
12
level 0
$ lsvg -o|lsvg -il
gisvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
loglv00 jfs2log 1 1 1 open/syncd N/A
fslv07 jfs2 480 480 1 open/syncd /gisdata
gis_bakvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
lv_gisbak jfs2 560 560 1 open/syncd /gisback
loglv05 jfs2log 1 1 1 open/syncd N/A
gx_bakvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
gx_baklv jfs2 1380 1380 1 open/syncd /nbgxzygl
loglv03 jfs2log 1 1 1 open/syncd N/A
rootvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
hd5 boot 1 2 2 closed/syncd N/A
hd6 paging 64 128 2 open/syncd N/A
2010年07月12日 05点07分
13
level 0
hd8 jfs2log 1 2 2 open/syncd N/A
hd4 jfs2 1 2 2 open/syncd /
hd2 jfs2 24 48 2 open/syncd /usr
hd9var jfs2 8 16 2 open/syncd /var
hd3 jfs2 1 2 2 open/syncd /tmp
hd1 jfs2 1 2 2 open/syncd /home
hd10opt jfs2 1 2 2 open/syncd /opt
fwdump jfs2 3 6 2 open/syncd /var/adm/ras/platform
lg_dumplv sysdump 8 8 1 open/syncd N/A
fslv00 jfs2 32 64 2 closed/syncd /ptfs
fslv01 jfs2 56 112 2 open/syncd /orainst
fslv02 jfs2 48 96 2 open/syncd /oracle
loglv04 jfslog 1 1 1 open/syncd N/A
lv00 jfs 8 8 1 open/syncd /dntfs
fslv05 jfs2 24 24 1 closed/syncd /aix-ptf
fslv06 jfs2 16 16 1 open/syncd /usr/tivoli
2010年07月12日 05点07分
14
level 0
$ lsvg -o|lsvg -il
gisvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
loglv00 jfs2log 1 1 1 open/syncd N/A
fslv07 jfs2 480 480 1 open/syncd /gisdata
gis_bakvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
lv_gisbak jfs2 560 560 1 open/syncd /gisback
loglv05 jfs2log 1 1 1 open/syncd N/A
gx_bakvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
gx_baklv jfs2 1380 1380 1 open/syncd /nbgxzygl
loglv03 jfs2log 1 1 1 open/syncd N/A
rootvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
hd5 boot 1 2 2 closed/syncd N/A
hd6 paging 64 128 2 open/syncd N/A
2010年07月12日 06点07分
15
level 0
hd8 jfs2log 1 2 2 open/syncd N/A
hd4 jfs2 1 2 2 open/syncd /
hd2 jfs2 24 48 2 open/syncd /usr
hd9var jfs2 8 16 2 open/syncd /var
hd3 jfs2 1 2 2 open/syncd /tmp
hd1 jfs2 1 2 2 open/syncd /home
hd10opt jfs2 1 2 2 open/syncd /opt
fwdump jfs2 3 6 2 open/syncd /var/adm/ras/platform
lg_dumplv sysdump 8 8 1 open/syncd N/A
fslv00 jfs2 32 64 2 closed/syncd /ptfs
fslv01 jfs2 56 112 2 open/syncd /orainst
fslv02 jfs2 48 96 2 open/syncd /oracle
loglv04 jfslog 1 1 1 open/syncd N/A
lv00 jfs 8 8 1 open/syncd /dntfs
fslv05 jfs2 24 24 1 closed/syncd /aix-ptf
fslv06 jfs2 16 16 1 open/syncd /usr/tivoli
2010年07月12日 06点07分
16