1、su – oracle 不是必需,适合于没有DBA密码时使用,可以不用密码来进入sqlplus界面。/ R2 a" X. h/ b6 T. |, C4 z
2、sqlplus /nolog 或sqlplus system/manager 或./sqlplus system/manager@ora9i;5 n1 Q) S% ^6 Q9 Y* |! h4 T( b. M. a3 B
3、SQL>connect / as sysdba ;(as sysoper)或- H( ~0 K* e7 @
connect internal/oracle AS SYSDBA ;(scott/tiger)
+ r- m- s1 J6 [3 @3 q) P! r9 econn sys/change_on_install as sysdba;
1 x' }# d/ N1 [' T: [4、SQL>startup; 启动数据库实例
{3 ]# o {% B2 _" h6 t2 K5 R5、 查看当前的所有数据库: select * from v$database;
( v* B. v9 O, i" Z" bselect name from v$database;7 X! o- L& H' f# ^( d, d- l
desc v$databases; 查看数据库结构字段
( ]' A* A E' {; R: J; c7、怎样查看哪些用户拥有SYSDBA、SYSOPER权限:
& C ~* ^7 w6 Y+ l+ W- dSQL>select * from V_$PWFILE_USERS;
$ N" i3 E, j+ u8 W( I0 bShow user;查看当前数据库连接用户
7 Y. W! q' Y# H# n" [2 b$ z! E% X8、进入test数据库:database test;
1 _# u7 \, Y7 [+ h9、查看所有的数据库实例:select * from v$instance;! ~* L7 K8 X! f
如:ora9i+ v1 d1 w, l4 @8 L# D# C
10、查看当前库的所有数据表: N J' v: J1 F" O \" R
SQL> select TABLE_NAME from all_tables;
. [2 }; r# ^ Iselect * from all_tables;) @. [1 o+ W" y H+ j
SQL> select table_name from all_tables where table_name like '%u%';- V! @1 `5 [8 A$ W( x* j0 E
% l" c/ ^) r- w% KTABLE_NAME; A: e3 |2 m6 H1 u
------------------------------+ q- _/ R- H8 x! d) X3 E
_default_auditing_options_
" B% s2 ]+ ~! a
! u. X+ B- Y. l11、查看表结构:desc all_tables;/ V, m7 b: E/ D& q% Y
12、显示CQI.T_BBS_XUSER的所有字段结构:& Q( N% y# I) _9 M8 R, ]
desc CQI.T_BBS_XUSER; " S* c1 ]& ^3 Z% Q. b4 ~1 S) P, [6 z/ ]
13、获得CQI.T_BBS_XUSER表中的记录:
* C, w& q$ \8 m* k4 T0 j( Jselect * from CQI.T_BBS_XUSER; n7 B* X3 \& [! a+ m! J
14、增加数据库用户:(test11/test)/ y: a; m) o: i6 ]% S7 e1 m5 W# o
create user test11 identified by test default tablespace users Temporary TABLESPACE Temp;! {; [1 b8 l F+ L7 a
15、用户授权: ( Z0 `& E% m' s/ X- v; r4 Q
grant connect,resource,dba to test11;' m4 H0 w, H/ B" M1 @3 a* n+ M
grant sysdba to test11;
/ R! p5 L! D- k7 O8 N5 R) Ncommit;4 r [$ q. _1 D/ s) o6 f
16、更改数据库用户的密码:(将sys与system的密码改为test.)
4 k: Q {9 `0 c4 `alter user sys indentified by test;! l2 U6 w" ?7 d. S5 I! e. e3 [
alter user system indentified by test;
- F7 I( V; E; b! | |