oracle 数据库,用户管理以及表空间等相关基础操作

 
开启超级管理员模式
sqlplus "/as sysdba"
修改BI账户密码为721521
alter user BI identified by 721521;
#修改时间格式
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
#查询被封的账户和被封时间
select username,lock_date from dba_users;
#解锁账号
alter user BI account unlock;
#解锁账号和同时取消密码过期
当前ORACLE用户的状态可查看视图DBA_USERS;一般情况下在使用的正常用户均处于OPEN状态。
select username,account_status from dba_users;
五种基本状态可分为三类:1.正常状态;2.锁定状态;3.密码过期状态。
1、OPEN状态表示用户处于正常状态。
2、LOCKED和LOCKED(TIMED)表示用户被锁定状态。
show all 查看系统所有变量值。
show user 显示当前连接用户
show error 显示错误
desc 表名 显示表结构。
/*   */ 多行注释
--单行注释
表空间: 数据库中最大的逻辑单位,每一个数据库至少有一个表空间。
三种类型:
 永久性表空间:存储表,视图,过程和索引等数据。
 临时表空间:保存系统中短期活动的数据。
 撤销表空间:回复回退未提交的事务数据。
 
表空间操作:
 create tablespace 表空间名
  datafile "数据文件路径" size 大小   --单位 K / M
  [autoextend no] [next 大小]
  [maxsize 大小];
 
 举个栗子:
  create tablespace test_ts
   datafile 'd:\oracle_data\test.dbf' size 10M
   autoextend no;
查询表空间:--管理员
select file_name, tablespace,bytes,autoextensible from dba_data_files where tablespace_name = 'test_ts';
 栗子
 --修改表空间
 alter tablespace 表空间名
  add datafile "数据文件路径" size 大小
  [autoextend no] [next 大小]
  [maxsize 大小];
删除表空间:
 drop tablespace 表空间名; --之删除表空间
 drop tablespace 表空间名 including contents and datafiles;  --删除表空间以及数据文件。
 
 
数据库用户系统
 常见用户:
  sys 超级用户
  sysdba :超级管理员
  system 默认系统管理员
  scott 示范用户
 
 
 查询系统用户:
  select * from all_users;
  select * from dba_users; --更详细的用户信息
  
  alter user hr account unlock  解锁hr用户
  
  
 创建用户:
  create user 用户名 identified by 密码
   default tablespace 表空间;
  
  栗子:
  create user test identified by 123456
   default tablespace test_ts
   temporary tablespace temp; --设置了临时表空间。
   
 修改密码:
  alter user 用户名 identified by 密码
  栗子:
  alter user test identified by 654321;
  
 删除用户:
  drop user 用户名 cascade;
 
 
 
 

猜你喜欢

转载自www.cnblogs.com/gaozd/p/9394894.html