通过pl/sql登录到Oracle数据库上,然后执行菜单:文件/新建/命令窗口 ,打开一个命令窗口然后在该命令窗口中执行脚本创建和删除表空间
创建表空间
create tablespace db_name_
datafile 'D:\oracle\product\10.2.0\oradata\orcl\db_name_.dbf' size 200M
autoextend on next 10M maxsize unlimited logging
extent management local autoallocate
segment space management auto;
1) DATAFILE: 表空间数据文件存放路径
2) SIZE: 起初设置为200M
3) UNIFORM: 指定区尺寸为128k,如不指定,区尺寸默认为64k
4) 空间名称:db_name_ 与 数据文件名称 db_name_.dbf 不要求相同,可随意命名.
5) AUTOEXTEND ON/OFF 表示启动/停止自动扩展表空间
6) alter database datafile ' D:\oracle\product\10.2.0\oradata\orcl\db_name_.dbf ' resize 500m; //手动修改数据文件大小为500M
7) DROP TABLESPACE db_name_ INCLUDING CONTENTS AND DATAFILES; //删除表空间
测试创建表空间
create tablespace IMSTEST
datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\HNORCL\IMTEST.def' size 200M
autoextend on next 20M maxsize unlimited logging
extent management local autoallocate
segment space management auto;
commit;
创建用户,设置DBA角色
CREATE USER MARTIN
IDENTIFIED BY martinpwd
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP;
例如:
--创建新用户
CREATE USER jack
IDENTIFIED BY "123"
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP"
grant connect to jack ;
grant dba to jack ;
grant sysdba to jack ;
//删除用户
drop user jack cascade;
[Oracle 10g]-关于表空间的更名
SQL> COL FILE_NAME format a70
SQL> SET linesize 120
SQL> SET pagesize 99
SQL> COL TABLESPACE_NAME format a10
SQL>
SQL> SELECT file_name, tablespace_name FROM dba_data_files;
删除用户名字
drop user PROJECTNAME cascade;
create tablespace TBS_PROJECTNAMETEST datafile 'D:\tbs_PROJECTNAME_test.dbf' size 20000M autoextend on next 1000M maxsize unlimited logging extent management local autoallocate segment space management auto;
CREATE USER PROJECTNAME
IDENTIFIED BY "PROJECTNAME"
DEFAULT TABLESPACE "TBS_PROJECTNAMETEST"
TEMPORARY TABLESPACE "TEMP" ;
grant connect to PROJECTNAME ;
grant dba to PROJECTNAME ;
grant sysdba to PROJECTNAME ;
创建无限表空间 Sql代码
CREATE TABLESPACE test DATAFILE
'D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORACLE\TEST1.DBF' SIZE 20000M AUTOEXTEND ON NEXT 1000M MAXSIZE UNLIMITED
LOGGING
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT MANUAL
FLASHBACK ON;