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

oracle数据库常用命令

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-13 16:42:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1、su – oracle 不是必需,适合于没有DBA密码时使用,可以不用密码来进入sqlplus界面。
, Q4 A1 _4 ]& {! f* z2、sqlplus /nolog 或sqlplus system/manager 或./sqlplus system/manager@ora9i;
9 k7 `/ Y$ ^" }4 P2 q- e$ J3、SQL>connect / as sysdba ;(as sysoper)或
: U2 S9 v5 P5 c1 F! Y; a  e' Bconnect internal/oracle AS SYSDBA ;(scott/tiger)
# [4 w$ ^/ f: ?& N+ k1 p; H# |: ^conn sys/change_on_install as sysdba;* A4 u: x0 J) ~7 `( G
4、SQL>startup; 启动数据库实例/ A6 b7 p5 W7 V; u4 n) {. x
5、 查看当前的所有数据库: select * from v$database;" S6 v! D3 \. |8 L( m1 j
select name from v$database;5 o1 C  j$ A8 w) ?
desc v$databases; 查看数据库结构字段
; O, Y4 \4 H7 H5 ^( G7、怎样查看哪些用户拥有SYSDBA、SYSOPER权限:: M2 @6 y: s5 s$ Q
SQL>select * from V_$PWFILE_USERS;
3 H. ]9 d; K6 {Show user;查看当前数据库连接用户# f8 v9 X& ~. u  l1 y
8、进入test数据库:database test; 8 Y! D1 ]2 o2 A; b! H& j
9、查看所有的数据库实例:select * from v$instance;( g3 I, d9 N! K, b3 N/ }0 I
如:ora9i
% y: z* _) {- C6 V10、查看当前库的所有数据表:: b; N+ ?, _3 ~8 `
SQL> select TABLE_NAME from all_tables; 2 q& {1 S% Z/ |; W2 Y, t3 l
select * from all_tables;
( u8 n9 W* G- `' h# F- w+ O2 USQL> select table_name from all_tables where table_name like '%u%';/ ?5 ~$ U, K3 s6 |
" U1 h$ |; K/ _
TABLE_NAME2 m$ q8 U5 R! f3 T: z
------------------------------; n; n$ R8 }' e' v: e9 B6 k
_default_auditing_options_5 [- Z9 _+ n# r9 S! |7 g
. s# @( o, A7 j( x3 Q7 `4 i. I
11、查看表结构:desc all_tables;
* S* W; `5 _8 u$ B& r! M12、显示CQI.T_BBS_XUSER的所有字段结构:; ^: i" Y+ |9 I. H' e3 Z; p
desc CQI.T_BBS_XUSER; ) o% m" q. y5 |/ k8 p" j" g+ o! E" L
13、获得CQI.T_BBS_XUSER表中的记录:" L/ n7 U2 Z& f: y! g" L6 e
select * from CQI.T_BBS_XUSER;
& n0 B6 Q( T; m' m14、增加数据库用户:(test11/test)
% M3 \( C- F7 _4 xcreate user test11 identified by test default tablespace users Temporary TABLESPACE Temp;# C/ ?& W( C) Y. f" W4 c
15、用户授权:
; u5 C4 b2 v/ ]; n6 G/ rgrant connect,resource,dba to test11;; c* H0 X) y* b
grant sysdba to test11;
) o! Z9 N; \! Z/ Vcommit;  k# H3 p* O0 ^2 X
16、更改数据库用户的密码:(将sys与system的密码改为test.)
- Y" Z( O- P9 J4 @. Qalter user sys indentified by test;8 b& ?! r5 c& V( V: x( s
alter user system indentified by test;
6 f3 x4 E1 S, n8 o
回复

使用道具 举报

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

本版积分规则

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