zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

Oracle 创建用户详解(create user)

Oracle 详解 用户 创建 user create
2023-06-13 09:11:40 时间

大家好,又见面了,我是你们的朋友全栈君。

文章目录

1 概述

创建用户

create user 用户名 identified by 密码;

DBA 用户执行

默认表空间:users

建议指定 表空间

默认临时表空间:temp

2 语法

2.1 创建

-- DBA 用户执行,默认 users 表空间(不推荐)create user <username> identified by <password>;-- 实际开发中create user <username> identified by <password> default tablespace <tablespace_name> -- 默认表空间temporary tablespace temp -- 临时表空间quota unlimited on <tablespace_name> -- 表空间额度grant create session to <username>; -- 授权(可以登录)

示例:创建用户 zhangsan 密码 12345,表空间 TESTTBS

create user zhangsan identified by 12345
default tablespace TESTTBS
temporary tablespace temp 
quota unlimited on TESTTBS;

grant create session TO zhangsan;

登录成功:

2.2 查询

select * 
  from dba_users t 
 where t.username = 'ZHANGSAN';

查询截图:

2.3 删除

-- zhangsan 必须已断开连接
drop user zhangsan cascade;

3 扩展

3.1 表空间

-- 创建
create tablespace TESTTBS -- 区分大小写
datafile 'E:\TableSpace\TESTTBS01.dbf' size 10m;

-- 查询表空间
select * 
  from dba_tablespaces t 
  where t.tablespace_name = 'TESTTBS';

-- 查询数据文件
select * 
  from dba_data_files t 
 where t.tablespace_name = 'TESTTBS';

扩展:Oracle 表空间详解(tablespace)

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/144680.html原文链接:https://javaforall.cn