1、su – oracle 不是必需,适合于没有DBA密码时使用,可以不用密码来进入sqlplus界面。
6 d! N, h' F% n7 y- f9 j2、sqlplus /nolog 或sqlplus system/manager 或./sqlplus system/manager@ora9i;
. b* C1 L) P3 o: B% r3、SQL>connect / as sysdba ;(as sysoper)或
! T4 E ]" k4 K1 L M6 ~! lconnect internal/oracle AS SYSDBA ;(scott/tiger)
( g; N P+ G% j! c% `conn sys/change_on_install as sysdba;; e$ v2 V+ |0 ^: G
4、SQL>startup; 启动数据库实例
5 z6 E, V" `& G! W7 B2 G5、 查看当前的所有数据库: select * from v$database;
* W2 }7 k% ^# H) h' f" W7 z1 eselect name from v$database;
2 j" S% q' m! a, y1 ydesc v$databases; 查看数据库结构字段* r# ^- A$ Q% J; d
7、怎样查看哪些用户拥有SYSDBA、SYSOPER权限:
9 [& x. }0 Q1 p0 i' K8 }& KSQL>select * from V_$PWFILE_USERS;1 |4 ]$ @# S b; ~2 I3 D4 y9 g# g- x6 ^
Show user;查看当前数据库连接用户3 v9 H2 t, T# ^2 Y! L2 U
8、进入test数据库:database test; + F7 x% |- _7 x
9、查看所有的数据库实例:select * from v$instance;% g! e) w8 h4 {( ^
如:ora9i3 D; `: q. C" J6 V; h, J d/ s
10、查看当前库的所有数据表:/ V( D, m# v# j. V. T; ^% l
SQL> select TABLE_NAME from all_tables;
0 V1 E0 }! z+ E' Tselect * from all_tables;; t9 H! i: d% H
SQL> select table_name from all_tables where table_name like '%u%';- Z( c6 ~7 O) u8 N
% \2 F% M8 r& ]7 q( ITABLE_NAME' L: C$ A8 V4 g! A0 f& v8 d; m$ @% S
------------------------------
4 X: ]9 u J- P& \' e- H* |, q_default_auditing_options_% h; B0 Z8 l* C% F5 Z
1 ~: o! t2 H L' b+ u; d# o9 \11、查看表结构:desc all_tables;
8 n7 y D) P, [9 c) N t7 G12、显示CQI.T_BBS_XUSER的所有字段结构:" u5 V' Z- U3 r1 e8 o0 U! Y
desc CQI.T_BBS_XUSER;
1 g$ K( D& ~! j- H' D13、获得CQI.T_BBS_XUSER表中的记录:5 g# B- P" ]8 `! ?& B5 y
select * from CQI.T_BBS_XUSER; 3 [& k! G. m. B7 ?2 {& l& F
14、增加数据库用户:(test11/test)$ t' G+ N2 @$ e! O
create user test11 identified by test default tablespace users Temporary TABLESPACE Temp;
. D% X# a# P# F' M' k9 S15、用户授权:
6 F" K6 v7 a4 {+ [8 j5 |, Q3 @9 lgrant connect,resource,dba to test11;$ Q* e8 j/ q: V5 s* V2 p4 b
grant sysdba to test11;
9 k/ R! x' M/ Y6 mcommit;7 [; \6 i6 L8 j8 i; q
16、更改数据库用户的密码:(将sys与system的密码改为test.)
8 c- N& D/ c+ P6 g3 b! b1 valter user sys indentified by test;
* u! @& Y" U% m$ |alter user system indentified by test; 4 P% l# J/ _2 a! \' c! Y
|