---
title: "SQL脚本创建表空间、用户、密码及授权"
author: "shang"
date: "2013-12-08T16:38:28Z"
tags: []
categories: ["数据库"]
slug: "sql"
draft: false
lastmod: "2013-12-08T16:38:28Z"
id: 1986816
url: "https://shang.iteye.com/blog/1986816"
---

sqlplus / as sysdba  
\-------------------------------

--建立永久表空间和临时表空间  
CREATE TABLESPACE TBS\_表空间  
    DATAFILE 'pda' SIZE 1000M AUTOEXTEND ON NEXT 102400K MAXSIZE UNLIMITED  
    EXTENT MANAGEMENT LOCAL AUTOALLOCATE  
    LOGGING  
    ONLINE  
    SEGMENT SPACE MANAGEMENT AUTO;

-- 新建一个用户  
create user 用户名  
  identified by 密码  
  default tablespace TBS\_表空间  
  temporary tablespace temp  
  profile DEFAULT;  
commit;  
\-- 授角色权限  
grant connect to 用户名 with admin option;  
grant exp\_full\_database to 用户名 with admin option;  
grant imp\_full\_database to 用户名 with admin option;  
grant resource to 用户名 with admin option;  
grant select\_catalog\_role to 用户名 with admin option;  
\-- 授系统权限  
grant select any dictionary to 用户名 with admin option;  
grant unlimited tablespace to 用户名 with admin option;  
commit;