create user dfdev identified by dfdev;
grant connect,resource,dba to dfdev;
REVOKE connect,resource,dba FROM dfdev;
GRANT connect, create any table, unlimited tablespace TO dfdev;
Base
sqlplus / as sysdba
Resource and link
-- 查看最大连接数
SELECT value FROM v$parameter WHERE name = 'processes';
-- 修改最大连接数(需重启)
ALTER SYSTEM SET processes = 2048 SCOPE = spfile;
-- 开启资源限定功能
ALTER SYSTEM SET resource_limit = true;
-- 修改时区
ALTER DATABASE SET time_zone='+8:00';
-- 查看DBA配置文件
SELECT * FROM DBA_PROFILES;
-- 默认配置设置连接超过30分钟后强制释放,连续不活动的会话超过5分钟后强制释放
ALTER PROFILE DEFAULT LIMIT IDLE_TIME 5;
ALTER PROFILE DEFAULT LIMIT CONNECT_TIME 30;
-- 创建连接超过30分钟后强制释放,连续不活动的会话超过5分钟后强制释放的配置
CREATE PROFILE RELEASE LIMIT CONNECT_TIME 30 IDLE_TIME 5;
-- 设置密码永不过期
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
-- 查询所有端的连接数此时分别是多少
SELECT b.MACHINE, b.PROGRAM, COUNT(*) FROM v$process a, v$session b WHERE a.ADDR = b.PADDR AND b.USERNAME IS NOT NULL GROUP BY b.MACHINE, b.PROGRAM ORDER BY COUNT(*) DESC;
-- 查询是否有死锁
SELECT * FROM v$locked_object;
Database and user
-- 启动
STARTUP
-- 立刻关闭
SHUTDOWN IMMEDIATE
-- 创建表空间(分配128m)
CREATE TABLESPACE dev0 DATAFILE '$ORACLE_BASE/oradata/dev0.dbf' SIZE 128m
-- 创建表空间(分配128m,自动拓展,每次拓展8m)
-- CREATE TABLESPACE dev0 DATAFILE '$ORACLE_BASE/oradata/dev0.dbf' SIZE 512m AUTOEXTEND ON NEXT 32m MAXSIZE UNLIMITED;
CREATE TABLESPACE dev0 DATAFILE '$ORACLE_BASE/oradata/dev0.dbf' SIZE 128m AUTOEXTEND ON NEXT 8m MAXSIZE UNLIMITED;
-- 创建用户
CREATE USER $UNAME IDENTIFIED BY $PWD DEFAULT TABLESPACE dev0;
-- 授予/撤销用户权限(最高权限,慎用)
GRANT/REVOKE dba TO/FROM $UNAME;
-- 授予/撤销用户权限(正常权限)
-- CREATE USER $UNAME IDENTIFIED BY $PWD DEFAULT TABLESPACE dev0 TEMPORARY TABLESPACE TEMP;
GRANT/REVOKE connect, create any table, unlimited tablespace TO/FROM $UNAME;
-- 解锁用户
ALTER USER $UNAME ACCOUNT UNLOCK;
-- 修改用户密码
ALTER USER $UNAME IDENTIFIED BY $PWD;
-- 删除USER
DROP USER $UNAME CASCADE;
-- 删除表空间
DROP TABLESPACE tablespace_name INCLUDING CONTENTS AND DATAFILES;
-- 删除空的表空间,不包含物理文件
DROP TABLESPACE tablespace_name;
-- 删除空表空间,包含物理文件
DROP TABLESPACE tablespace_name INCLUDING DATAFILES;
-- 删除非空表空间,不包含物理文件
DROP TABLESPACE tablespace_name INCLUDING DATAFILES;
-- 删除非空表空间,包含物理文件
DROP TABLESPACE tablespace_name INCLUDING CONTENTS AND DATAFILES;