2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Oracle表領域とユーザーの操作

Last updated at Posted at 2015-10-04

環境

  • Oracle Database XE 11.2

参照
OS X で Vagrant な Ubuntu に Oracle XE をインストール
OS X Mavericks に Oracle Client と ruby-oci8 をインストール

表領域

確認

SELECT TABLESPACE_NAME, STATUS, BIGFILE FROM DBA_TABLESPACES;
SELECT FILE_NAME FROM DBA_DATA_FILES;

-- 表領域の使用量
SELECT
  D.TABLESPACE_NAME,
  MB, 
  AVAIL,
  ROUND((1 - (AVAIL / MB)) * 100) "USE%"
FROM
  (SELECT TABLESPACE_NAME, ROUND(SUM(BYTES) / (1024 * 1024)) MB
FROM DBA_DATA_FILES GROUP BY TABLESPACE_NAME) D,
  (SELECT TABLESPACE_NAME, ROUND(SUM(BYTES) / (1024 * 1024)) AVAIL
FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) F
WHERE D.TABLESPACE_NAME=F.TABLESPACE_NAME;

作成
スモール・ファイル表領域'FOO'を100Mで作成する。

CREATE TABLESPACE FOO 
  DATAFILE '/u01/app/oracle/oradata/XE/foo.dbf' SIZE 100M
  SEGMENT SPACE MANAGEMENT AUTO;

削除

DROP TABLESPACE FOO
INCLUDING CONTENTS AND DATAFILES;

ユーザー

確認

SELECT * FROM ALL_USERS;
SELECT USERNAME FROM DBA_USERS;
-- デフォルト表領域
SELECT USERNAME, DEFAULT_TABLESPACE FROM USER_USERS;
-- ユーザー'FOO_USER'の表領域を確認する
SELECT USERNAME, DEFAULT_TABLESPACE FROM DBA_USERS WHERE USERNAME='FOO_USER';

作成
表領域'FOO'にユーザー'FOO_UESR'をパスワード'FOO_PASS'で作成する。

CREATE USER FOO_USER IDENTIFIED BY FOO_PASS
DEFAULT TABLESPACE FOO;

-- DBAロールを割り当てる
GRANT DBA TO FOO_USER;
-- サイズ無制限の権限を付与する
GRANT UNLIMITED TABLESPACE TO FOO_USER;
-- 接続権限を付与する
GRANT CONNECT TO FOO_USER;
exit

sqlplus FOO_USER/FOO_PASS@xe
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?