Oracle数据库创建表空间用户21-11-25

Posted mingyuewu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle数据库创建表空间用户21-11-25相关的知识,希望对你有一定的参考价值。

Oracle数据库创建表空间、用户

1 登录oralce数据库

# sysdba
sqlplus '/ as sysdba'
# 普通用户
conn  xiaoming/"123456"

2 创建表空间


create  tablespace  ONEPAY   datafile'/data/oracle/oradata/orcl12c/ONEPAY_CORE.dbf'  size 512M
autoextend on next 512M maxsize unlimited extent management local;


create  tablespace  ONEPAY_INDEX   datafile'/data/oracle/oradata/orcl12c/ONEPAY_INDEX.dbf'  size 512M
autoextend on next 512M maxsize unlimited extent management local;

3 创建用户

# 指定用户的默认表空间及第二表空间
create user ONEPAY identified by "123456" default tablespace ONEPAY_CORE profile DEFAULT;
ALTER USER  ONEPAY  QUOTA UNLIMITED ON ONEPAY_INDEX;


#######授权
-- Grant/Revoke role privileges 
grant connect to onepay;
grant dba to onepay;
grant resource to onepay;
-- Grant/Revoke system privileges 
grant create any synonym to onepay;
grant create session to onepay;
grant unlimited tablespace to onepay;

4 授权

grant connect,resource , dba to ONEPAY;
grant create view to ONEPAY;
grant create public synonym to ONEPAY;
grant drop public synonym to ONEPAY;
grant unlimited tablespace to ONEPAY;
grant read,write on directory dir_dump to ONEPAY;

5 查询验证

/* 查用户及其默认表空间*/
select  * from  dba_users;   //DBA用户
select  *  from  dba_tablespaces;
select  *  from  user_users;  //普通用户
select  username,default_tablespace from user_users;   //普通用户
/* 查看.dbf文件 */
select name from v$datafile;  //DBA用户
select * from dba_data_files;  //DBA用户
/* 查看表 */
SELECT * FROM  ALL_TABLES  WHERE  OWNER='ONEPAY';
SELECT table_name FROM user_tables ORDER BY Table_name;
/*查看oralce服务名和SID*/
 select global_name from global_name;  //DBA身份
  select instance_name from v$instance;

6 删除用户和表空间

DROP USER username CASCADE; 

DROP TABLESPACE tablespace-name INCLUDING CONTENTS AND DATAFILES;

7 执行SQL文件

登录到对应用户
@ 路径
@/data/onepay.sql

8 创建表

create table WMY.student_info (
  sno         number(10) constraint pk_si_sno primary key,
  sname       varchar2(10),
  sex         varchar2(4),
  create_date date
);
-- 添加注释
comment on table WMY.student_info is '学生信息表';
comment on column WMY.student_info.sno is '学号';
comment on column WMY.student_info.sname is '姓名';
comment on column WMY.student_info.sex is '性别';
comment on column WMY.student_info.create_date is '创建日期';


insert into WMY.student_info (sno, sname, sex, create_date)
values (1, '张三', '男', sysdate);
insert into WMY.student_info (sno, sname, sex, create_date)
values (2, '李四', '女', sysdate);
insert into WMY.student_info (sno, sname, sex, create_date)
values (3, '王五', '男', sysdate);

以上是关于Oracle数据库创建表空间用户21-11-25的主要内容,如果未能解决你的问题,请参考以下文章

Oracle数据库创建表空间用户21-11-25

oracle以啥用户创建表空间

oracle 创建表空间、创建用户

oracle怎样创建表空间和用户

oracle 怎么授权用户 只能在指定的表空间中 创建表

如何彻底删除oracle创建的用户和表空间