找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2112|回复: 0
打印 上一主题 下一主题

oracle数据库常用命令

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-13 16:42:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1、su – oracle 不是必需,适合于没有DBA密码时使用,可以不用密码来进入sqlplus界面。2 }2 _/ c( J0 z* j: x
2、sqlplus /nolog 或sqlplus system/manager 或./sqlplus system/manager@ora9i;5 R; V5 f2 P- K- }) F1 c* I
3、SQL>connect / as sysdba ;(as sysoper)或* O+ Q  V, G1 h2 e6 V4 V1 ?: }! k
connect internal/oracle AS SYSDBA ;(scott/tiger)
9 w" q0 w/ ]+ `6 X  s0 [  t$ |9 jconn sys/change_on_install as sysdba;
; A( ]) U4 u. i2 h9 L8 a5 R4、SQL>startup; 启动数据库实例
+ u. l% \' J/ C% ^5 I: e5、 查看当前的所有数据库: select * from v$database;$ W& Y# V) G6 K# w2 n. p9 j% k0 M
select name from v$database;
, t( a. T: m6 Ndesc v$databases; 查看数据库结构字段
7 C2 b, J& I! n  j  G4 G4 ], z$ ]7、怎样查看哪些用户拥有SYSDBA、SYSOPER权限:5 \/ m$ n" I7 _4 u0 x$ E2 L$ z
SQL>select * from V_$PWFILE_USERS;
6 B* e# i5 M1 q8 I  S# d$ KShow user;查看当前数据库连接用户8 t8 g/ F9 p: |& l1 L$ e, a
8、进入test数据库:database test;
5 y0 Q: P* b2 \% e  o+ ]: j9、查看所有的数据库实例:select * from v$instance;
6 e3 y" m6 j4 w; D5 @; y如:ora9i
2 e' k# R+ `+ l10、查看当前库的所有数据表:
% @1 q( V8 l" _9 p+ A1 @0 |" Y! g3 HSQL> select TABLE_NAME from all_tables; + m& Q, d; S) {
select * from all_tables;/ @8 J8 d9 b; N* }9 m
SQL> select table_name from all_tables where table_name like '%u%';+ @9 g5 B3 r1 f9 ?) ]1 a
$ l7 f- K- c, `/ }
TABLE_NAME
% d2 Q. o; T& t* Z------------------------------2 C9 p- k+ x- b$ @* Z
_default_auditing_options_8 I6 j1 |5 H$ v$ z# Y% u/ e
; z; ]3 u1 s/ [4 h7 x9 s) ~
11、查看表结构:desc all_tables;
% y# A: C. F% Y12、显示CQI.T_BBS_XUSER的所有字段结构:8 _8 @" j: J2 ?! q
desc CQI.T_BBS_XUSER;
$ h; i  d( F7 ^* f' g( w& ^13、获得CQI.T_BBS_XUSER表中的记录:
4 Y3 p6 x  J$ Wselect * from CQI.T_BBS_XUSER; & T' V! U  L0 [" R# L% g
14、增加数据库用户:(test11/test)
4 P8 R  Z8 @9 vcreate user test11 identified by test default tablespace users Temporary TABLESPACE Temp;
) S7 _0 ^5 }- I$ b6 \, T6 J; O15、用户授权:
& g. S0 M- s2 P6 h+ Igrant connect,resource,dba to test11;7 n# a: d& S* W/ s
grant sysdba to test11;3 S" N. x0 j) w7 ^* f! N: C4 v% ]
commit;
) Q+ C3 n; r$ c) ?4 i16、更改数据库用户的密码:(将sys与system的密码改为test.)! t" M# f0 b6 h2 x8 Q! A4 K. T
alter user sys indentified by test;5 k+ O2 J) Y3 M5 P) c
alter user system indentified by test;   \+ Q' K1 d9 J! x6 j4 e7 t
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表