sql - 在 Oracle 数据库中创建用户

标签 sql database oracle createuser

我是 Oracle 数据库的第一个用户。

现在,我想创建一个名为 ERDB 的数据库模式。

我需要创建 ERDB 用户并向 ERDB 用户授予对 SQL 脚本文件的适当权限。

CREATE USER dmuser IDENTIFIED BY password 
DEFAULT TABLESPACE USERS 
TEMPORARY
TABLESPACE TEMP 
QUOTA UNLIMITED ON USERS;
GRANT CREATE JOB TO dmuser; 
GRANT CREATE MINING MODEL TO dmuser; 
GRANT CREATE PROCEDURE TO dmuser; 
GRANT CREATE SEQUENCE TO dmuser;
GRANT CREATE SESSION TO dmuser; 
GRANT CREATE SYNONYM TO dmuser; 
GRANT CREATE TABLE TO dmuser; 
GRANT CREATE TYPE TO dmuser; 
GRANT CREATE VIEW TO dmuser; 
GRANT EXECUTE ON ctxsys.ctx_ddl TO dmuser; 

但是报错了,SQL Error: ORA 01031 insufficient privileges;

请帮助我。

最佳答案

Oracle documentation明确说明如下:

Prerequisites

You must have the CREATE USER system privilege.

SYSTEM连接,不需要SYSDBA然后执行:

CREATE USER user IDENTIFIED BY password 

类似地,执行其他命令来创建表空间和所需的授权等。

旁注,关于SYSDBA:

  • Never ever use SYS (or SYSDBA) but for maintenance purpose (startup, shutdown, backup, recover)
  • SYS/SYSDBA is special
  • SYS/SYSDBA is Oracle proprietary (try to open a SR/TAR starting with "i did that with SYS/SYSDBA" and you'll see the immediate answer)
  • SYS/SYSDBA does not act like any other user
  • When you use SYS/SYSDBA Oracle deactivates some code path and activates others
  • Whatever you do with SYS/SYSDBA will neither validate nor invalidate the same thing with any other user.

NEVER EVER use SYS/SYSDBA for anything that can be done by another user. Use SYS/SYSDBA ONLY for something that can't be done by someone else.

关于sql - 在 Oracle 数据库中创建用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34452574/

相关文章:

c# - .NET 异步 Oracle 连接的方法

oracle - 我有一个程序,我想比较带来日期并带来所需的数据

mysql - 获取每小时累计金额

python - 如何使用 cx_Oracle 运行非查询 sql 命令?

php - 如何从数据库中回显包含特定变量的行

asp.net-mvc - 从网站向数据库中插入 100k 行

ruby-on-rails - Rails 建模问题 - 关系和主键

sql - 查询 Db 中具有特定数据类型的所有主键

sql - 将表达式树解析为 Sqlstring - 不是重新发明轮子

php - 找到第一个达到目标的用户