oracle数据库创建

oracle数据库安装完成之后如何创建表空间呢?也就是数据库的创建。

创建表空间

1
2
3
4
SQL>CREATE TABLESPACE BigData LOGGING DATAFILE '/usr/local/app/oracle/oradata/orcl/BigData.dbf' 
SIZE 100M AUTOEXTEND ON NEXT 32M MAXSIZE 500M EXTENT MANAGEMENT LOCAL;
# 查看
SQL>select name from v$datafile;

创建临时表空间

1
2
3
4
SQL>create temporary tablespace BigData_temp tempfile '/usr/local/app/oracle/oradata/orcl/BigData_temp.dbf'
size 100m autoextend on next 32m maxsize 500m extent management local;
# 查看
SQL>select name from v$tempfile;

关联用户

1
SQL>create user letour identified by BigData default tablespace BigData temporary tablespace BigData_temp;

授权处理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
grant connect,resource to letour;
查询已创建的用户
select username from dba_users;
# 将用户的密码设置为123456。
alter user letour identified by 123456;
解锁用户:
alter user letour account unlock;
创建会话的权限
grant create session to letour;
查询用户下所有表
SELECT * FROM ALL_TABLES WHERE OWNER= 'LETOUR';
授予用户对该表空间的UNLIMITED配额
ALTER USER LETOUR QUOTA UNLIMITED ON BigData;
授权resource角色给用户之后,便可以创建表
GRANT RESOURCE TO LETOUR;

数据库管理

1
2
3
4
5
6
7
8
9
10
11
12
# 删除表空间
drop tablespace space_name including contents and datafiles;
# 修改表空间大小(注:修改=可以增大,可以减小)
alter database datafile '/u01/app/oracle/oradata/ORCL/ittbank.dbf' resize 200m;
# 增加表空间大小(注:增加=只能增大,不能减少)
alter tablespace space_name add datafile '/u01/app/oracle/oradata/ORCL/ittbank.dbf' size 2048m;
# 查询数据库文件:
select * from dba_data_files;
# 表空间情况
select tablespace_name,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
# 查询表空间剩余空间
select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by tablespace_name;

×

谢谢客官

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. 创建表空间
  2. 2. 创建临时表空间
  3. 3. 关联用户
  4. 4. 授权处理
  5. 5. 数据库管理
,