转自:http://jackroomage.iteye.com/blog/675769
1、window下创建oracle用户及表空间
--创建数据表空间
create tablespace oras_data --表空间的名字
logging
datafile 'D:\oracle\product\10.1.0\oradata\oras_data.dbf' --表空间的文件,注意据库版本,我的是10.1.0
size 32m
autoextend on
next 32m maxsize 2048m
extent management local; --这里是让表空间自动增长
--创建用户并指定表空间
create user oras identified by oras --创建用户及密码
default tablespace oras_data; --把用户指定那个表空间
--给用户授予权限
grant dba,connect,resource,CTXAPP,create view to oras;--给用户受的一些权限
2、linux下创建oracle用户及表空间
操作步骤如下:
1、登录linux,以oracle用户登录(如果是root用户登录的,登录后用 su - oracle命令切换成oracle用户)
2、以sysdba方式来打开sqlplus,命令如下: sqlplus "/as sysdba"
3、查看我们常规将用户表空间放置位置:执行如下sql:
select name from v$datafile;
上边的sql一般就将你的用户表空间文件位置查出来了。
--创建数据表空间
create tablespace oras_data --表空间的名字
logging
datafile '/oracle/product/10.1.0/oradata/oras_data.dbf' --表空间的文件,注意据库版本,我的是10.1.0
size 32m
autoextend on
next 32m maxsize 2048m
extent management local --这里是让表空间自动增长
--创建用户并指定表空间
create user oras identified by oras --创建用户及密码
default tablespace oras_data --把用户指定那个表空间
--给用户授予权限
grant dba,connect,resource,CTXAPP,create view to oras;--给用户受的一些权限
总结:不同点,
1、 window下:
logging
datafile 'D:\oracle\product\10.1.0\oradata\oras_data.dbf'
2、Linux下:
logging
datafile '/oracle/product/10.1.0/oradata/oras_data.dbf'
3、Linux下:
里面的sql语句的末尾,一般不要加 ";" 号。会执行不了。如下,应该把后面的";"去掉。
grant dba,connect,resource,CTXAPP,create view to oras;--给用户受的一些权限
别的都一样了,很简单的。
--###########################################
--查看所有表空间的使用多少
select tablespace_name,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
--查看指定的表空间被索引和表各占了多少表空间。
select SEGMENT_TYPE,owner,sum(bytes)/1024/1024 from
dba_segments
where tablespacE_name='ORAS_DATA'
group by segment_type,owner
--删除用户,会删除此用户名下的所有表和视图
drop user oras cascade
--删除表空间
drop tablespace oras_data including contents and datafiles
补充知识
转自:http://database.51cto.com/art/200910/158936.htm
1、先查询空闲空间
- select tablespace_name,file_id,block_id,bytes,blocks from dba_free_space;
2、增加Oracle表空间
先查询数据文件名称、大小和路径的信息,语句如下:
- select tablespace_name,file_id,bytes,file_name from dba_data_files;
3、修改文件大小语句如下
- alter database datafile
- '需要增加的数据文件路径,即上面查询出来的路径
- 'resize 800M;
4、创建Oracle表空间
- create tablespace test
- datafile '/home/app/oracle/oradata/oracle8i/test01.dbf' size 8M
- autoextend on
- next 5M
- maxsize 10M;
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize unlimited
- maxsize unlimited 是大小不受限制
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- extent management local uniform;
- unform表示区的大小相同,默认为1M
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- extent management local uniform size 500K;
- unform size 500K表示区的大小相同,为500K
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- extent management local autoallocate;
- autoallocate表示区的大小由随表的大小自动动态改变,大表使用大区小表使用小区
- create tablespace sales
- datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- temporary;
- temporary创建字典管理临时表空间
- create temporary tablespace sales
- tempfile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
- autoextend on
- next 50M
- maxsize 1000M
- 创建本地管理临时表空间,如果是临时表空间,所有语句中的datafile都换为tempfile
- 8i系统默认创建字典管理临时表空间,要创建本地管理临时表空间要加temporary tablespace关键字
- 创建本地管理临时表空间时,不得使用atuoallocate参数,系统默认创建uniform管理方式
- 为表空间增加数据文件:
- alter tablespace sales add
- datafile '/home/app/oracle/oradata/oracle8i/sales02.dbf' size 800M
- autoextend on next 50M
- maxsize 1000M;
创建本地管理临时Oracle表空间,如果是临时表空间,所有语句中的datafile都换为tempfile8i系统默认创建字典管理临时表空间,要创建本地管理临时表空间要加temporary tablespace关键字创建本地管理临时表空间时,不得使用atuoallocate参数,系统默认创建uniform管理方式
为表空间增加数据文件:
- alter tablespace sales add
- datafile '/home/app/oracle/oradata/oracle8i/sales02.dbf' size 800M
- autoextend on next 50M
- maxsize 1000M;
5、更改自动扩展属性:
- alter database datafile
- '/home/app/oracle/oradata/oracle8i/sales01.dbf',
- '/home/app/oracle/oradata/oracle8i/sales02.dbf'
- '/home/app/oracle/oradata/oracle8i/sales01.dbf
- autoextend off;
转载请注明本文地址: window,linux下创建oracle用户及表空间 对比 易于学习