Skip to content

Instantly share code, notes, and snippets.

@adiberr
Last active August 4, 2024 00:41
Show Gist options
  • Select an option

  • Save adiberr/e613190791f1349b7578086cf3e24b7a to your computer and use it in GitHub Desktop.

Select an option

Save adiberr/e613190791f1349b7578086cf3e24b7a to your computer and use it in GitHub Desktop.
Create a new Oracle user for testing

Connect as SYSDBA :

sqlplus / as sysdba

Fix a down Database :

STARTUP MOUNT;
ALTER DATABASE OPEN;

Check if listener is running :

lsnrctl status
lsnrctl stop
lsnrctl start

Check connected user :

SELECT USER FROM DUAL;

Check if PDB exists :

-- In CDB
SELECT NAME, CON_ID FROM DBA_PDBS;
-- In PDB
SELECT NAME FROM DBA_PDBS;

Switch to PDB :

ALTER SESSION SET CONTAINER = PDB1;

Create a new user :

CREATE USER app_user IDENTIFIED BY password DEFAULT TABLESPACE users QUOTA UNLIMITED ON users;

Grant connect and resource :

GRANT CONNECT, CREATE SESSION, RESOURCE TO app_user;

Check user creation and privileges :

SELECT USERNAME FROM DBA_USERS WHERE USERNAME = 'APP_USER';
SELECT * FROM DBA_TS_QUOTAS WHERE USERNAME = 'APP_USER';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment