1、su – oracle 不是必需,适合于没有DBA密码时使用,可以不用密码来进入sqlplus界面。
6 r- Y I! ^+ h0 U s) Q S2、sqlplus /nolog 或sqlplus system/manager 或./sqlplus system/manager@ora9i;
1 y9 A. s/ n- S8 I* L& B4 ?' s+ ?3 E3、SQL>connect / as sysdba ;(as sysoper)或
3 ?! |) R! K, Y, x0 X; rconnect internal/oracle AS SYSDBA ;(scott/tiger)9 Q9 p3 r m0 x. O
conn sys/change_on_install as sysdba;; B4 p r7 H8 |. x2 u( ], B ^
4、SQL>startup; 启动数据库实例
+ D+ W, e$ L: F1 ?0 v: F5、 查看当前的所有数据库: select * from v$database;
& g& O6 b$ b' |# `) cselect name from v$database;: [' N. X* g& O3 q
desc v$databases; 查看数据库结构字段) Q' ?! T/ F, y( Z; J% A6 A* R
7、怎样查看哪些用户拥有SYSDBA、SYSOPER权限:
; }% a! y; G1 l0 hSQL>select * from V_$PWFILE_USERS;
/ C( Q G# x" n; |# @6 BShow user;查看当前数据库连接用户
/ J5 d+ m7 a0 s3 c1 {8、进入test数据库:database test; , Q6 v) x" v5 v0 t5 u
9、查看所有的数据库实例:select * from v$instance;
# F, {1 e: P) o* M3 @如:ora9i
. R* y6 z, [' N: E, r) {10、查看当前库的所有数据表:
, I- W( t8 y0 g( j0 h5 V7 J9 U. D* rSQL> select TABLE_NAME from all_tables;
- ^9 C( Z( q% }, cselect * from all_tables;; c& }+ @( G6 Y/ ~) v% j8 j
SQL> select table_name from all_tables where table_name like '%u%';
3 | ?( G5 [1 o5 p0 T
7 ^3 Q% m# U( k5 D$ N+ e1 `# `TABLE_NAME
3 q; N5 o; Q' }1 R------------------------------* L4 D ]. }" A$ I( ]
_default_auditing_options_/ c2 S: L0 }7 n. l: t* G! |" t
5 m2 m3 o" L& j- h" ^1 t11、查看表结构:desc all_tables;: r' {8 _' { K0 p" V
12、显示CQI.T_BBS_XUSER的所有字段结构:" k1 e1 E7 u4 A l; U
desc CQI.T_BBS_XUSER; ( `" Q$ L: y0 J d2 A0 j
13、获得CQI.T_BBS_XUSER表中的记录:
, l9 t3 h" ]. F- U7 z2 gselect * from CQI.T_BBS_XUSER; 9 K& D5 P( p. l9 e+ ]0 }% U
14、增加数据库用户:(test11/test)
+ _1 a: [- V; X, acreate user test11 identified by test default tablespace users Temporary TABLESPACE Temp;
% V L& ? J3 H6 _1 J15、用户授权: ; u7 ?; P6 M* m$ }* |1 ^
grant connect,resource,dba to test11; O6 A5 ?6 N5 s0 F
grant sysdba to test11;7 V' a. O; G; s* x7 P- [
commit;
6 a# a0 a& Z) H16、更改数据库用户的密码:(将sys与system的密码改为test.)( e5 {, J: [( U* k H7 _- _. t! f
alter user sys indentified by test;3 i2 j) X7 L* X/ r. J
alter user system indentified by test; - o( R0 I7 w2 S6 x$ y
|