Home Database Oracle How to add users in oracle

How to add users in oracle

Dec 24, 2021 pm 03:06 PM
oracle

In Oracle, you can use the "create user" command to add users. The function of this command is to create a new user. The syntax is "create user username identified by password [i.e. password];".

How to add users in oracle

The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.

The permission system of Oracle database is divided into system permissions and object permissions. System privilege (database system privilege) allows users to execute a specific set of commands. For example, the create table permission allows the user to create a table, and the grant any privilege permission allows the user to grant any system permission.

Object privilege (database object privilege) allows users to perform certain operations on each object. For example, the delete permission allows users to delete rows in a table or view, and the select permission allows users to query information from tables, views, sequences, or snapshots through select.

Each oracle user has a name and password, and has some tables, views and other resources created by it. An oracle role is a set of privileges (or the type of access each user requires based on their status and conditions). Users can grant or assign specified permissions to roles, and then assign the roles to the corresponding users. A user can also directly authorize other users.

1. Create users

There are two built users inside oracle: system and sys.

Users can log in directly to the system user to create other users, because system has the ability to create another user. permissions of the user. When installing Oracle, the user or system administrator can first create a user for himself.

Syntax [Create User]: create user username identified by password [i.e. password];

Example:

create user test identified by test;
Copy after login

Syntax [change user]: alter user username identified by password[changed password] ];

Example:

 alter user test identified by 123456;
Copy after login

2. Delete user

Syntax: drop user username;

Example:

drop user test;
Copy after login

If the user owns the object, it cannot be deleted directly, otherwise an error value will be returned. Specify the keyword cascade to delete all objects of the user and then delete the user.

Syntax: drop user username cascade;

Example:

drop user test cascade;
Copy after login

3. Authorization role

Oracle provides three standard roles (role) for compatibility with previous versions: connect/resource and dba.

(1) Explain the three standard roles:

1 》. connect role (connection role)

--Temporary users, especially users who do not need to create tables, usually only give them connect role.

--Connect is a simple permission to use Oracle, This permission only has access rights to other users' tables, including select/insert/update and delete, etc.

--Users with connect role can also create tables, views, sequences, clusters, synonyms, sessions and other data links

2》. resource role(resource role)

--More reliable and formal database users can be granted resource role.

--resource provides users with additional permissions to create their own tables, sequences, procedures, triggers, indexes, and clusters.

3》. dba role (database administrator role)

--dba role has all system permissions

--including unlimited space quotas and to other users The ability to grant various permissions. The system is owned by the dba user

(2) Authorization command

Syntax: grant connect, resource to username;

Example: grant connect, resource to test;

(3) Revoke permissions

Syntax: revoke connect, resource from username;

Example: revoke connect, resource from test;

4. Create/Authorize/Delete Roles

In addition to the three system roles mentioned earlier - connect, resource and dba, users can also create their own roles in Oracle. User-created roles can consist of table or system permissions or a combination of both. In order to create a role, the user must have the create role system permission.

1》Create role

Syntax: create role role name;

Example:

create role testRole;
Copy after login

2》Grant role

Syntax: grant select on class to role name;

Liezi:

grant select on class to testRole;
Copy after login

Note: Now , all users with the testRole role have select query permissions on the class table

3》Delete role

Syntax: drop role role name;

Example:

drop role testRole;
Copy after login

Note: All permissions related to the testRole role will be deleted from the database

Recommended tutorial: "Oracle Tutorial"

The above is the detailed content of How to add users in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to add and replace hard disks in oracle rac How to add and replace hard disks in oracle rac Apr 11, 2025 pm 05:39 PM

Oracle RAC hard disk new and replacement operations: Add hard disk: Add new disks, create ASM disk groups, add to clusters, move data files. Replace hard disk: Identify the failed hard disk, close the disk group, replace the hard disk, reopen the disk group, repair the failed disk, and move the data files.

How to deal with oracle garbled code How to deal with oracle garbled code Apr 11, 2025 pm 07:00 PM

Oracle garbled problems are usually caused by improper character set settings. Solutions include: Checking the server, database, and client character sets. Set up the server, database, and client character sets as needed. Use the CONVERT function or the DBMS_LOB.CONVERT_LOB function to fix garbled data. Always specify the character set and set the NLS parameters correctly.

How to re-query oracle How to re-query oracle Apr 11, 2025 pm 07:33 PM

Oracle provides multiple deduplication query methods: The DISTINCT keyword returns a unique value for each column. The GROUP BY clause groups the results and returns a non-repetitive value for each group. The UNIQUE keyword is used to create an index containing only unique rows, and querying the index will automatically deduplicate. The ROW_NUMBER() function assigns unique numbers and filters out results that contain only line 1. The MIN() or MAX() function returns non-repetitive values ​​of a numeric column. The INTERSECT operator returns the common values ​​of the two result sets (no duplicates).

How to check tablespace size of oracle How to check tablespace size of oracle Apr 11, 2025 pm 08:15 PM

To query the Oracle tablespace size, follow the following steps: Determine the tablespace name by running the query: SELECT tablespace_name FROM dba_tablespaces; Query the tablespace size by running the query: SELECT sum(bytes) AS total_size, sum(bytes_free) AS available_space, sum(bytes) - sum(bytes_free) AS used_space FROM dba_data_files WHERE tablespace_

How to connect to a cloud server How to connect to a cloud server Apr 11, 2025 pm 06:51 PM

The steps to connect to a cloud server through an Oracle client are as follows: Create an SSH key and copy the public key to the cloud server. Configure the Oracle client and add the connection information of the cloud server to the tnsnames.ora file. Create a new database connection in the Oracle client, enter the username, password, and DSN. Click OK and verify that the connection is successful.

Summary of basic knowledge of oracle database Summary of basic knowledge of oracle database Apr 11, 2025 pm 06:33 PM

Oracle Database is a reliable, scalable and feature-rich relational database management system (RDBMS). Its architecture follows the client-server model, including server-side components (Oracle Net), instances, shared memory areas (SGAs), background processes, and database files that store data. Basic concepts include tables, rows, columns, primary keys, foreign keys, indexes and cursors. The database is known for its advantages such as high availability, big data support, rich features, strong security and ease of use.

How to modify oracle character set How to modify oracle character set Apr 11, 2025 pm 06:57 PM

To modify the Oracle character set, you need to: back up the database; modify the character set settings in the init.ora file; restart the database; modify existing tables and columns to use the new character set; reload the data; modify the database link (optional).

How to use stored procedures for oracle How to use stored procedures for oracle Apr 11, 2025 pm 07:03 PM

A stored procedure is a set of SQL statements that can be stored in a database and can be called repeatedly as a separate unit. They can accept parameters (IN, OUT, INOUT) and provide the advantages of code reuse, security, performance and modularity. Example: Create a stored procedure calculate_sum to calculate the sum of two numbers and store them in the OUT parameter.

See all articles