oracle dba需要的基本命令

Oracle基础总结

                                                     

一、基础知识

   数据库连接

   Sqlplus 用户名/密码 as sysdba;

   Sqlplus "/ as sysdba";

   Sqlplus /nolog;

   后面两个是忘记密码的情况下登录数据库

   --connect / as sysdba;

   一般用户第一次连接可以更改密码。

   创建用户

   --create user 用户名 identified by 密码;

   给用户设置密码

   --alter user sys id identified by password;

   --alter user system identified by password;

   授权

   --grant dba to scott;

   --grant select on dba_users to scott;

   --grant select,delete on scott emp to test;

     回收授权

   --revoke select on dba_users from scott;

   --revoke select,delete on scott emp from test;

   --conn / as sysdba;

   锁定用户

   --alter user 用户名account lock;

   为用户解锁

   --alter user 用户名 account unlock;

   强行关闭

   --shutdown abort;

   启动

   --startup;

   查看当前用户

   --show user;

   查看scott拥有那些表 (查看当前连接用户有那些表)

   --select table_name from user_tables;

   创建视图

   --create view emp_v as select * from emp;

   --select * from emp_v;

   设置环境变量

   这个sqlplus环境是在系统初始化时加载的 glogin.sql 文件,环境变量都保存在这个文          

   件中。

   -- E:\oracle\product\10.1.0\db_1\sqlplus\admin目录下 的glogin.sql文 件 打开它    

    在里面加入:

   -- set linesize 100
   -- set pagesize 1000
   -- set long 20000
   -- set serveroutput on

授权与收回权限测试 (授予出去的权限可以全部收回)

create user cuug identified by cuug;

grant connect to cuug;

grant resource to cuug;

测试with grant option的含义( 意思是授权给别人

connect / as sysdba

grant select on dba_tables to  scott   with grant option;  

connect scott/tiger

select count(*) from dba_tables;

grant select on dba_tables to cuug ;

connect cuug/cuug

select count(*) from dba_tables;

connect / as sysdba

revoke select on dba_tables from scott;

connect scott/tiger

select count(*) from dba_tables;

connect cuug/cuug

select count(*) from dba_tables;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值