show sga
set wrap off
set linesize 400
— 查看正在运行的后台进程
select * from v$bgprocess;
select * from v$bgprocess where paddr<>’00’;
–查看数据库的物理组成:文件情况
select * from v$controlfile;
select * from v$datafile;
select * from v$logfile;
–查看实例内存情况
show parameter sga
show parameter shared
show parameter db_cache
show parameter log
alter system set db_cache_size=64m; //可以动态修改sga中内存区的大小,但是不能超过sga的最大内存
select * from dept;
–表空间管理
CREATE TABLESPACE tbs2
DATAFILE ‘D:\oracle\oradata\APTECH\tbs2_01.dbf’
SIZE 50M;
conn sys/admin as sysdba(重启数据库必须以sys用户登陆)
shutdown immediate(关闭数据库)
启动数据库的三个步骤:
startup nomount (启动实例)
alter database mount;(装载数据库,读取控制文件)
alter database open;(打开数据库,对数据文件,日志文件进行一致性校验)
–用户管理
— Create the user
CREATE USER MARTIN
IDENTIFIED BY martinpwd
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP;
— Grant role privileges
GRANT CONNECT TO MARTIN;
GRANT RESOURCE TO MARTIN;
— 如果不使用 CONNECT 角色,则需要逐个赋予用户权限
GRANT CREATE SESSION TO MARTIN;
GRANT CREATE TABLE TO MARTIN;
GRANT CREATE VIEW TO MARTIN;
GRANT CREATE SEQUENCE TO MARTIN;
GRANT CREATE SEQUENCE TO MARTIN;
GRANT SELECT ON TEST TO MARTIN;
GRANT ALL ON TEST TO MARTIN;
— 授予用户使用表空间 USERS 的权限
ALTER USER MARTIN
QUOTA UNLIMITED ON USERS;
–修改用户密码
ALTER USER MARTIN IDENTIFIED BY martinpass;
–修改自己的密码
在sql*plus中直接输入password命令即可
–删除用户
DROP USER MARTIN CASCADE;
— 查看用户 MARTIN 的信息
select USERNAME,USER_ID,DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE
from dba_users
where username = ‘MARTIN’;