1、表空间相关sql
-- 创建表空间名为test_tablespace_name,存储位置为D:\DB\oradata\orcl\test_tablespace_name.dbf,大小为128m,无限制,超出后每次增长10m create tablespace test_tablespace_name datafile ‘D:\DB\oradata\orcl\test_tablespace_name.dbf‘ size 128m autoextend on next 10m maxsize unlimited; -- 查看表空间名为test_tablespace_name信息 SELECT file_name, tablespace_name, bytes, autoextensible FROM dba_data_files WHERE tablespace_name = ‘test_tablespace_name‘; -- 删除表空间 test_tablespace_name alter tablespace test_tablespace_name offline; -- 将磁盘上的数据文件一同删除 drop tablespace test_tablespace_name including contents and datafiles;
2、用户相关sql
-- 新建用户 test_user/test_password,指定表空间为test_tablespace_name create user test_user identified by test_password default tablespace test_tablespace_name temporary tablespace temp; -- 修改用户密码 ALTER USER test_user identified by 123456; -- 删除用户 DROP USER test_user CASCADE; -- 锁定用户 alter user test_user account lock; -- 解锁用户 alter user test_user account unlock; -- 查询用户信息 select * from all_users; -- 更详细的用户信息 select * from dba_users;
3、授权相关sql
-- 授予test_user用户dba权限 grant resource, dba, connect, create any table, create any index, create any sequence, unlimited tablespace to test_user; -- 撤销test_user用户dba权限 REVOKE resource, dba, connect, create any table, create any index, create any sequence, unlimited tablespace FROM test_user; --查看当前用户的系统权限 select * from user_sys_privs; --查看当前用户的对象权限 select * from user_tab_privs; --查看当前用户的所有角色 select * from user_role_privs;
yexiangyang