CREATE TEMPORARY TABLESPACE "temp_yourname" TEMPFILE '/u01/app/oracle/oradata/orcl/temp_yourname.dbf' SIZE 20M AUTOEXTEND ON NEXT 32M MAXSIZE 2048M EXTENT MANAGEMENT LOCAL;注1:一般数据库实例安装完成后默认有临时表空间“TEMP”,如果小型数据库用此临时表空间即可。
CREATE TABLESPACE "yourname" LOGGING DATAFILE '/u01/app/oracle/oradata/orcl/yourname.dbf' SIZE 20M AUTOEXTEND ON NEXT 32M MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;注1:DATAFILE是单引号,否则会报“ORA-00972: identifier is too long”。
CREATE USER yourname IDENTIFIED BY yourname DEFAULT TABLESPACE yourname TEMPORARY TABLESPACE temp_yourname;
GRANT connect, resource, dba TO yourname;
================================================
根据网友建议,提供PL/SQL的模板文件,文件源码如下:
[$WINDOW TYPE = SQL] -- 1. Create temporary tablespace. CREATE TEMPORARY TABLESPACE "temp_[Name(lower-case)="yourname"]" TEMPFILE '[DB File Dir="/u01/app/oracle/oradata/orcl"]/temp_[Name(lower-case)="yourname"].dbf' SIZE 20M AUTOEXTEND ON NEXT 32M MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL; -- 2. create user tablespace. CREATE TABLESPACE "[Name(lower-case)="yourname"]" LOGGING DATAFILE '[DB File Dir="/u01/app/oracle/oradata/orcl"]/[Name(lower-case)="yourname"].dbf' SIZE 20M AUTOEXTEND ON NEXT 32M MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL; -- 3. create user. CREATE USER [Name(lower-case)="yourname"] IDENTIFIED BY [Name(lower-case)="yourname"] DEFAULT TABLESPACE [Name(lower-case)="yourname"] TEMPORARY TABLESPACE temp_[Name(lower-case)="yourname"]; -- 4. grant to user. GRANT connect, resource, dba TO [Name(lower-case)="yourname"];
1、新建:工具 -> 模板列表 ,右击 -> “新模板”...粘贴模板文件源码。
2、使用:新建SQL窗口 -> 双击模板 -> 输入参数(修改默认值如下图)...。
3、生成SQL代码
(完)