Home  >  Article  >  Database  >  Oracle 10g表空间创建的完整步骤

Oracle 10g表空间创建的完整步骤

WBOY
WBOYOriginal
2016-06-07 16:53:23971browse

1.创建表空间不论是Lnux环境,还是Wndows环境,都要首先创建好表空间的存放路径,如:/opt/oracle/oradata/cocis 或 D:\oracle\o

Oracle Version:Oracle10.2.0.1

Author: Cocis

当在数据库中创建用户时,基于应用性能和管理方面的考虑,最好为不同的用户创建独立的表空间。

1.创建表空间

不论是Lnux环境,还是Wndows环境,都要首先创建好表空间的存放路径,如:

/opt/oracle/oradata/cocis 或 D:\oracle\oradata\cocis

若事先不创建该目录路径,则在创建表空间的时候会出错。

然后执行如下命令:

SQL> create tablespace cocis

2 datafile 'D:\oracle\oradata\cocis\cocis01.dbf'

3 size 100M AutoExtend On Next 10M Maxsize 2048M

4 extent management local

5 segment space management auto

6 /

表空间已创建。

2.为应用创建用户

创建用户的同时,为用户指定缺省的永久表空间和临时表空间。

SQL> create user cocis identified by cocis

2 default tablespace cocis

3 temporary tablespace temp;

用户已创建。

SQL> select username,default_tablespace,temporary_tablespace

2 from dba_users

3 where username='COCIS';

USERNAME                       DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE

------------------------------ ------------------------------ ------------------

COCIS                          COCIS                          TEMP

SQL> select username,user_id,password,default_tablespace,temporary_tablespace

2 from dba_users

3 where username='COCIS';

USERNAME                          USER_ID PASSWORD                       TEMPORARY_TABLESPACE

------------------------------ ---------- ------------------------------ -----------------------

COCIS                                  61 E031F623C0F15D34               COCIS

3.权限的授予

SQL> grant connect,resource to cocis;

授权成功。

注释:当用户创建之后,一般只需要授予CONNECT和RESOURCE这两个角色即可。若要单独进行授权,则需执行单独的授权命令,,如grant create table to cocis;等。

SQL> revoke unlimited tablespace from cocis;

撤销成功。

SQL> alter user cocis quota unlimited on cocis;

用户已更改。

注释:为了更严谨的管理,可以回收用户的UNLIMITED TABLESPACE权限,然后对用户的空间限额进行单独授权。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn