oracle创建用户四部曲

创建用户一般分四步:

第一步:创建临时表空间

第二步:创建数据表空间

第三步:创建用户并制定表空间

第四步:给用户授予权限

创建临时表空间

create temporary tablespace homehotel_temp
tempfile 'D:/win64_Oracle_11gR2/homehotel/homehotel_temp.dbf'
size 50m
autoextend on
next 50m maxsize 1024m
extent management local;

注意事项:文件目录要存在D:/win64_Oracle_11gR2/homehotel,dbf为oracle创建的文件名,不能存在,由oracle创建。

创建数据表空间

create tablespace homehotel_data
logging
datafile 'D:/win64_Oracle_11gR2/homehotel/homehotel_data.dbf'
size 50m
autoextend on
next 50m maxsize 1024m
extent management local;

注意事项:与临时表空间一样要求。

创建用户并制定表空间

create user homehotel identified by homehotel
default tablespace homehotel_data
temporary tablespace homehotel_temp;

给用户授予权限

grant connect,resource,dba to homehotel; 

查看用户信息以及空间存储

select username,default_tablespace,user_users.* from user_users;

--删除空的表空间,但是不包含物理文件
drop tablespace tablespace_name;
--删除非空表空间,但是不包含物理文件
drop tablespace tablespace_name including contents;
--删除空表空间,包含物理文件
drop tablespace tablespace_name including datafiles;
--删除非空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles;
--如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;

原文地址:https://www.cnblogs.com/miaosj/p/6932177.html