安装好Oracle数据库和客户端后, 服务器端用lsnrctl start启动监听程序, 在客户端用net config 配置,
连接数据库, 最后生成tnsnames.ora文件, 格式如下(这是管理两个节点的配置).
#C:\oracle\ora92\NETWORK\ADMIN\tnsnames.ora
servicename =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.120.1.70)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test)
)
)
TEST_2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.120.1.71)(PORT = 1526))
)
(CONNECT_DATA =
(SERVICE_NAME = myora)
)
)
可以用tnsping servicename来测试连接
然后sqlplus username/passwd@servicename 连接
常见问题:
<>; ORA-12537: TNS: 连接已关闭
A:监听程序没有启动, 运行lsnrctl start命令
<>;ORA-12545: 因目标主机或对象不存在,连接失败
A: 检查tnsnames.ora文件配置, 主机名和端口是否正确, 监听程序是否启动.
<>;ORA-12560: TNS:protocol adapter error
A: 检查tnsnames.ora文件配置, 主机名和端口是否正确, 监听程序是否启动. SID是否正确,
可以用tnsping 检测
<>;ORA-03113 :通信通道的文件结束
A:这个原因的问题很多, 一般应检查网络状况, 或者系统参数的配置
具体见: http://www.chinaunix.net/cgi-bin/bbs/topic.cgi?forum=8&topic=393&show=2340
<>; select 查询时,有2000条记录符合条件,如何先取出符合条件前1000条,然后再取出符合条件的后1000条?
A:
select * from table_name where rownum<=1000;
select * from table_name where rownum<=2000 minus select * from table_name where rownum<=1000;
select * from table_name where rownum<=3000 minus select * from table_name where rownum<=2000;
<>;怎样能够查到数据库的名字?
A: select value from v$parameter where upper(name) like '%DB_NAME%'
<>;怎样得到一个表的最后更新时间?
A: 1. 打开审计功能, 设置初始化文件: AUDIT_TRAIL = true
2. 重新启动instance.
3. 审计表:
AUDIT INSERT,SELECT,DELETE,UPDATE on TableName
by ACCESS WHENEVER SUCCESSFUL
4. 得到详细信息:
SELECT OBJ_NAME,ACTION_NAME ,to_char(timestamp,'dd/mm/yyyy , HH:MM:SS')
from sys.dba_audit_object.
<>;察看表空间都有哪些表
A; select table_name from dba_tables where tablespace_name='xxx';
<>; 一个不常见的错误:
$ sqlplus
exec(): 0509-036 Cannot load program sqlplus because of the following errors:
0509-130 Symbol resolution failed for sqlplus because:
0509-136 Symbol pw_post (number 272) is not exported from
dependent module /unix.
0509-136 Symbol pw_wait (number 273) is not exported from
dependent module /unix.
0509-136 Symbol pw_config (number 274) is not exported from
dependent module /unix.
0509-136 Symbol aix_ora_pw_version3_required (number 275) is not exported from
A: 重新 /etc/loadext -l /etc/pw-syscall (reload)
可能是 Oracle Kernel Extension for aix 在服务器重启动的时候没 load