oracle 表空间、临时表空间、创建用户、导入数据、导出数据

时间:2022-04-03 12:14:20
-- 创建 表空间
CREATE SMALLFILE TABLESPACE tablespacename DATAFILE 'F:\oracle/tablespacename' SIZE 500M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;


-- 创建 临时表空间
CREATE SMALLFILE TEMPORARY TABLESPACE temptablespacename TEMPFILE 'F:\oracle/temptablespacename' SIZE 200M AUTOEXTEND ON NEXT 25M MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

--删除表空间 drop tablespace tablespacename including contents and datafiles

--创建用户 确定用户是否存在
DROP USER username CASCADE;

-- Create the user 创建用户
create user username
  identified by "password"
  default tablespace tablespacename
  temporary tablespace temptablespacename
  profile DEFAULT;
-- Grant/Revoke role privileges 为用户赋权限
grant connect to username with admin option;
grant dba to username with admin option;
-- Grant/Revoke system privileges
grant unlimited tablespace to username  with admin option;


--导入数据
imp username/password@orcl full=y file=保存有数据库文件的完整路径.dmp ignore=y
--导出数据
exp username/password@orcl file=存放数据库文件的完整路径.dmp