- 论坛徽章:
- 0
|
用命令行启用帐户 先解锁后 一定要设密码 不然还是无法登陆
默认的scott用户是被锁定的,先解锁就能登陆上了。
使用下面的语句解锁scott:
alter user scott
account unlock;
解锁之后可能会要求你该密码:
alter user scott
identified by tiger;
再登陆:
sqlplus scott/tiger
就能登陆了
sqlplus / as sysdba;//登陆sys帐户
sqlplus sys as sysdba;//同上
sqlplus scott/tiger;//登陆普通用户scott
hr用户解锁
SQL> alter user hr
2 account unlock;
SQL> alter user hr
2 identified by hr;
实例
SQL> select instance_name,status from v$instance;
SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
显示表名的各个字段
desc 表名
SQL> desc dba_tablespaces;
数据字典
SQL> select count(*) from dictionary;
SQL> select table_name
2 from dict
3 where table_name like '%CONSTRAIN%';
查看体系结构
show parameter spfile 参数恢复
SQL> show parameter
SQL> show parameter shared_pool_si
SQL> show parameter db_cache_size
SQL> show parameter log_buffer
SQL> show parameter java_pool_
SQL> show parameter large_pool
SQL> show parameter stream
SQL> show parameter sga_target '分配给其他参数
SQL> SELECT COMPONENT,CURRENT_SIZE/1024/1024||'M' "size"
2 from V$SGA_DYNAMIC_COMPONENTS;
SQL> select name
2 from v$bgprocess
3 where paddr <> '00';
SQL> select name from v$datafile;
SQL> select * from v$tablespace;(查看表空间)
SQL> select tablespace_name
2 from user_tablespaces/dba_tablespaces;
SQL> select name from v$controlfile;
SQL> select group#,member from v$logfile order by group#;
SQL> select GRANTED_ROLE (查看用户角色)
2 from user_role_privs;
管理用户
create user zhangsan;//在管理员帐户下,创建用户zhangsan
授予权限
/*管理员授权*/
grant create session to zhangsan; //授予zhangsan用户创建session的权限,即登陆权限
grant unlimited session to zhangsan;//授予zhangsan用户使用表空间的权限
grant create table to zhangsan; //授予创建表的权限
grante drop table to zhangsan; //授予删除表的权限
grant insert table to zhangsan; //插入表的权限
grant update table to zhangsan; //修改表的权限
grant all to public; //这条比较重要,授予所有权限(all)给所有用户(public)
oralce对权限管理比较严谨,普通用户之间也是默认不能互相访问的,需要互相授权
grant select on tablename to zhangsan; //授予zhangsan用户查看指定表的权限
grant drop on tablename to zhangsan; //授予删除表的权限
grant insert on tablename to zhangsan; //授予插入的权限
grant update on tablename to zhangsan; //授予修改表的权限
grant insert(id) on tablename to zhangsan;
grant update(id) on tablename to zhangsan;//授予对指定表特定字段的插入和修改权限,注意,只能是insert和update
grant alert all table to zhangsan; //授予zhangsan用户alert任意表的权限
撤销权限
基本语法同grant,关键字为revoke
SQL> revoke create session from zhangsan;
SQL> revoke create table from user001;
SQL> revoke select on dept from user001;
查看权限
select * from user_sys_privs;//查看当前用户所有权限
select * from user_tab_privs;//查看所用用户对表的权限
查看当前用户拥有的表
SQL> select table_name from user_tables;
SQL> select owner,table_name
2 from dba_tables
3 where table_name='T003';
查看数据库对象
select distinct object_type from dba_objects;
权限传递
即用户A将权限授予B,B可以将操作的权限再授予C,命令如下:
grant alert table on tablename to zhangsan with admin option;//关键字 with admin option
grant alert table on tablename to zhangsan with grant option;//关键字 with grant option效果和admin类似
【更多相关资源详见oracle群共享:300179148】 |
|