Why is it impossible to drop user despite it exists in dba_users view - oracle

I try to drop/alter user like this
drop user AVASILIEV_AXIOM_10X
And I get the following error
SQL> drop user AVASILIEV_AXIOM_10X;
drop user AVASILIEV_AXIOM_10X
*
ERROR at line 1:
ORA-01918: user 'AVASILIEV_AXIOM_10X' does not exist
But this user exists in the dba_users view:
SQL> select username from dba_users where username='AVASILIEV_AXIOM_10X';
USERNAME
------------------------------
AVASILIEV_AXIOM_10X
SQL>
Also, I can't create user with the same name because it already exists in the DB. What's the problem?
My Oracle version:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
"CORE 11.2.0.4.0 Production"
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

This is old thread but for reference Oracle Doc ID 1297361.1 suggests as follows:
SQL> drop user ahong3;
drop user ahong3
*
ERROR at line 1:
ORA-01918: user 'AHONG3' does not exist
SQL> select username from dba_users where username='ahong3';
USERNAME
------------------------------
ahong3
SQL> execute hcheck.full
HCheck Version 8i-11/1.95
Found 0 potential problems and 0 warnings
PL/SQL procedure successfully completed.
CAUSE
User was created forcibly in lower case. Drop user considers the user to be in upper case, and hence can't find it.
Ex: below statement will force the creation of the user in lower case.
SQL> Create user "ahong3";
SOLUTION
Force the drop user statement to drop the user created in lower case by specifying the user name in double quotes:
SQL> Drop user "ahong3";
This solution worked for me

DROP USER user CASCADE;
Hope this work cz its work for me

Related

Recompiling a synonym in another schema of Oracle DB

I want to recompile a broken synonym in another schema but get an error about privileges.
As per Oracle states:
To modify a private synonym in another user's schema, you must have the CREATE ANY SYNONYM and DROP ANY SYNONYM system privileges.
Okay, see my snippet:
SQL*Plus: Release 11.2.0.1.0 Production on Thu Sep 24 18:47:29 2020
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Release 11.2.0.4.0 - 64bit Production
SQL> select user, sys_context( 'userenv', 'current_schema' ) cur_schema from dual;
USER
------------------------------
CUR_SCHEMA
--------------------------------------------------------------------------------
STAT_ADM
STAT_ADM
SQL> SELECT s.privilege
2 FROM dba_sys_privs s
3 WHERE s.grantee = USER
4 AND s.privilege LIKE '%ANY%SYNONYM%';
PRIVILEGE
----------------------------------------
DROP ANY SYNONYM
CREATE ANY SYNONYM
SQL> alter synonym ADB011_T_PRO.SA_BRAND compile;
alter synonym ADB011_T_PRO.SA_BRAND compile
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> select dbms_metadata.get_ddl(object_type => 'SYNONYM'
2 ,NAME => 'SA_BRAND'
3 ,SCHEMA => 'ADB011_T_PRO') ddl_code from dual;
DDL_CODE
--------------------------------------------------------------------------------
CREATE OR REPLACE SYNONYM "ADB011_T_PRO"."SA_BRAND" FOR "STAT_INT"."SA_BRAND"
SQL>
Do I really lack of some permission? Or how should I properly recompile synonym? I have also CREATE ANY SYNONYM permission so I workaround it by issuing DDL statement of this synonym to make it valid again but I want to use a compile option.
This does seem to be documented as Oracle Bug 4189542 (Doc ID 4189542.8). From your code, it looks like you are using a version 11.2.0.4 database. If you update your version of Oracle, or apply a recent patch set to your 11.2.0.4 database, then it should resolve the issue.

Oracle Application Express 11g

I am new to Oracle and want to practice SQL.
I downloaded the Application Express Edition 11g for Windows x64. I followed instructions and created a workspace and user.
However when I try to create a table I get an error "ORA-20000: User xxx has no privileges on the schema. Error checking privileges.
However when I go and look at the user in the administration is says that I am the workspace administrator. I also cannot seem to log in as SYSTEM or SYS using the password I created when I installed.
I am very confused.
There are two terms you are dealing with:
a database, which contains tables and data - tables belong to users such as SYS or SYSTEM - you should not use them at all, except for unlocking existing user (HR or SCOTT; whichever it is) in order to use it for practicing
Application Express, which is a tool you use to access the database and create applications which will manage data stored in your tables. Once you log on as admin, you can create workspaces (which are mapped to database users/schemas) and developers (who will create applications). This "admin" user is very different from database owners (sys/system), so you can't log on to Apex using sys as username and its password
As you installed the 11g XE database (which has built-in Apex version 4.x, I think - it is not Apex 11g, it doesn't exist), at the operating system command prompt run SQL*Plus and connect as SYS:
C:\>sqlplus sys#xe as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Sub Lis 6 20:26:19 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>
List users in the database:
SQL> select username, account_status from dba_users order by username;
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
ANONYMOUS OPEN
APEX_PUBLIC_USER LOCKED
APEX_040000 LOCKED
APPQOSSYS EXPIRED & LOCKED
CTXSYS EXPIRED & LOCKED
DBSNMP EXPIRED & LOCKED
DIP EXPIRED & LOCKED
FLOWS_FILES LOCKED
HR LOCKED
IMPORTER OPEN
MDSYS EXPIRED & LOCKED
MIKE OPEN
ORACLE_OCM EXPIRED & LOCKED
OUTLN EXPIRED & LOCKED
SCOTT OPEN
SYS OPEN
SYSTEM OPEN
XDB EXPIRED & LOCKED
XS$NULL EXPIRED & LOCKED
19 rows selected.
SQL>
See the HR (human resources) user? It is locked. We'll unlock it and change its password (to "hr") so that you could use it in Apex, as it already contains several tables full of data.
SQL> alter user hr account unlock;
User altered.
SQL> alter user hr identified by hr;
User altered.
SQL>
Connect as HR, just to see what it contains:
SQL> connect hr/hr#xe
Connected.
SQL> select * From tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
COUNTRIES TABLE
DEPARTMENTS TABLE
DEPT TABLE
EMPLOYEES TABLE
EMP_DETAILS_VIEW VIEW
INSTRUCTOR TABLE
JOBS TABLE
JOB_HISTORY TABLE
LOCATIONS TABLE
PRODUCT TABLE
REGIONS TABLE
RIGHTS TABLE
TEACHES TABLE
USERS TABLE
14 rows selected.
SQL>
If you want to create your own tables, do it in HR schema. As I said, leave SYS and SYSTEM alone; they are special, you don't use them for everyday purposes. If you do something unusual, you might destroy the database.
OK; now run Apex, connect as admin, navigate to "Manage workspaces" and:
create workspace - follow the wizard. When asked, "re-use existing schema" answer "Yes" and select HR from list of values
manage developers and users - create user. Follow the wizard. As a workspace, select previously created workspace, set the password
Once you're done, logout of admin and logon as newly created user - provide workspace name, username and password - that should let you in. Once you're in Apex - as a developer - you can create your first page (an interactive report might be a good choice).
Good luck!
[EDIT: built-in Apex on 11gXE]
click Start - All programs - Oracle database 11g Express Edition - Get started
a page opens, offering several red buttons; the last of them is "Application Express"; click it
login asks for database user with DBA privileges; enter username = SYS (or SYSTEM) and its password
you're now redirected to "create Apex workspace" page. Items' labels are underlined; it means that they contain help (feel free to click). The first item is "Database user" radio button which offers "Create new" and "Use existing" - you'd choose "Use existing"
for "Database username", choose "HR" from select list. HR is now unlocked, right? If it is expired, make sure you altered it in order to set the password (alter user hr identified by hr)
Application Express username (and password) represents username related to Apex (i.e. not the database user) - you'll use it to log on to Apex
If you want to see which workspaces already exist, connect to the database as SYS (using SQLPlus at the operating system command prompt):
C:\>sqlplus sys#xe as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Ned Lis 7 12:40:34 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> select * from all_users where username like 'APEX%';
USERNAME USER_ID CREATED
------------------------------ ---------- --------
APEX_040000 47 29.05.14
APEX_PUBLIC_USER 45 29.05.14
SQL> -- describe table that contains info about workspaces
SQL> desc apex_040000.apex_workspaces
Name Null? Type
----------------------------------------- -------- ----------------------------
WORKSPACE NOT NULL VARCHAR2(255)
SOURCE_IDENTIFIER VARCHAR2(8)
SCHEMAS NUMBER
LAST_PURGED_SESSION DATE
ALLOW_APP_BUILDING_YN VARCHAR2(1)
ALLOW_SQL_WORKSHOP_YN VARCHAR2(1)
ALLOW_WEBSHEET_DEV_YN VARCHAR2(1)
ALLOW_TEAM_DEVELOPMENT_YN VARCHAR2(1)
ALLOW_TO_BE_PURGED_YN VARCHAR2(1)
SESSIONS NUMBER
APPLICATIONS NUMBER
APPLICATION_PAGES NUMBER
APEX_USERS NUMBER
APEX_DEVELOPERS NUMBER
APEX_WORKSPACE_ADMINISTRATORS NUMBER
FILES NUMBER
SQL_SCRIPTS NUMBER
TRANSLATION_MESSAGES NUMBER
FILE_STORAGE NUMBER
LAST_LOGGED_PAGE_VIEW DATE
PAGE_VIEWS NUMBER
WORKSPACE_ID NOT NULL NUMBER
SQL> col workspace format a10
SQL> select workspace, source_identifier, apex_developers
2 from apex_040000.apex_workspaces;
WORKSPACE SOURCE_I APEX_DEVELOPERS
---------- -------- ---------------
HR HR 1
INTERNAL 0
SQL>
If HR workspace already contains, it means that you've already created it.
In web browser, connect as admin (use address http://127.0.0.1:8080/apex/apex_admin). (Workspace name is "internal"; you don't have to enter it). Username = admin, password = ... huh, not sure. Try SYS password. If you can't connect, you can change that password. Locate file named APXCHPWD.SQL ("Apex change password") on your disk; for example, it'll be in C:\oraclexe\app\oracle\product\11.2.0\server\apex\apxchpwd.sql directory. In SQLPlus, connected as SYS, execute that file:
SQL> show user
USER is "SYS"
SQL> #C:\oraclexe\app\oracle\product\11.2.0\server\apex\apxchpwd.sql
Enter a value below for the password for the Application Express ADMIN user.
Enter a password for the ADMIN user []
Session altered.
...changing password for ADMIN
PL/SQL procedure successfully completed.
Commit complete.
SQL>
Admin will now have password you've just typed, so - back to Apex admin, connect; you'll have to change that password so - do it, and connect again.
You'll now see "Manage Workspaces" button. In there, there are numerous links which do stuff. If you want, you can remove the HR workspace (following the "Remove Workspace" link) and create it back again.
The next step is to create a developer - use "Manage Developers and Users" link. Once you do that, you should be able to log on to Apex as developer, using "HR" as workspace name, developer username and password as credentials.
In order to be able to simultaneously adjust Apex as admin and connect as a developer, open a new connection using a different browser (for example, Chrome for one thing, Internet Explorer for another) - if you use the same browser (but different tabs or even a new browser session entirely), it won't work - new connection will terminate previous one.
I hope that the above will get you started.
Apparently, built-in Apex version is 4.0.2 (quite old one, at least 5-6 years), but will do at the beginning. Upgrade to a more recent version isn't difficult - download it and run SQL file which does everything for you. Just follow the Installation Guide.
I'd also suggest you to read & follow 4.0 Apex User's Guide, so that I wouldn't have to create a tutorial here, on Stack Overflow :)

Failed to create view contains v$view

In sqlplus under normal schema account (not sys), query select * from v$instance; runs OK. But when create view which references it, error happens:
create or replace view vw_test_instance
as
select * from V$instance;
SQL Error: ORA-01031: insufficient privileges
If switch v$instance to any normal table like select * from dual;, then the view created with no problem.
Oracle version:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
"CORE 11.2.0.4.0 Production"
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
The back ground is I'm upgrading a database run on 10g to 11g, things used to work on 10g just broken on 11g... Can I fix it without touching source code of views? Appreciated!
This is related to user GRANTS.
1. GRANT SELECT ON V$INSTANCE TO <USER>; --> Will be provided by SYSDBA
2. Then try. It will definitley help.
This link will also help you to understand why this kind of behaviour occurs.
v$views Grant
"query select * from v$instance; runs OK. But when create view which references it, error happens:"
The error you get - SQL Error: ORA-01031: insufficient privileges - indicates that your user lacks the privileges to create a view.
" things used to work on 10g just broken on 11g"
Clearly on 10g privileges your user had privileges to create views and on 11g they do not.
The most likely explanation is that your user relies on the CONNECT role. In older versions of Oracle this role had several system privileges, including CREATE VIEW. This implicit granting of privileges was always dodgy. However, in 11g this changed and the role now only has CREATE SESSION. All other privileges must be granted explicitly. This is mentioned in the 11g Upgrade docs and explained in depth by the 11g Security Guide Find out more.

Oracle can only login as sysdba / can't login with configured user?

So I created the user w3038519 in the Oracle database configuration as I was installing Oracle yet it does not let me login with it.
C:\Users\Chris>sqlplus w13038519/mypass
SQL*Plus: Release 12.1.0.1.0 Production on Fri Aug 14 00:26:16 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
Could the account be locked somehow? Is there any way I can unlock it or create another user? The following doesn't work
sqlplus w13038519/mypass as sysdba
sqlplus osauthentication/anyuserpass as sysdba
SQL> create user chris
2 identified by chrispass
3 ;
create user chris
*
ERROR at line 1:
ORA-65096: invalid common user or role name
SQL> create user C##chris
2 identified by chrispass
3 ;
create user C##chris
*
ERROR at line 1:
ORA-65048: error encountered when processing the current DDL statement in
pluggable database PDBORCL
ORA-01031: insufficient privileges
I can't do anything I need to with sysdba because you can't create triggers logged in sysdba
I watched some tutorial and the person just setup sysdba as I have done and now can't use triggers.
I hate oracle so much. It's so retarded to use the most unideal platform there is
You have created a container database instead of a traditional one. In this case, When you use / as sysdba, you connect to the root container, where you can not create reguler users, only common users (starting with c##), so your user w13038519 can not exist in the root container. Run the below query:
select con_id from cdb_users where username = 'W13038519';
CON_ID
----------
3
This should return the container database where your user was created. If you get no result, your user does not exist. To find the name of the container:
SQL> select name from v$pdbs where con_id = 3;
NAME
------------------------------
PDB1
If you have a TNS entry pointing to that container database, you can connect as:
sqlplus w13038519/september23#PDB1
If you do not need the Multitenant Architechture specifically, you will save yourself a lot of trouble by creating a traditional database.
create user C##TESTDB identified by TESTDB container = all;
ORA-65048: error encountered when processing the current DDL statement in
pluggable database PDBORCL
ORA-01031: insufficient privileges
in my case this worked
alter session set "_oracle_script"=true;
create user C##TESTDB identified by TESTDB;
user created;

Oracle 12.1.0.2.0 - User creation successful but connection with new user fails

D:\app\Administrator\product\12.1.0\dbhome_1\BIN>sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Oct 30 12:51:12 2014
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> CREATE USER johndoe IDENTIFIED BY johndoe
2 DEFAULT TABLESPACE "USERS"
3 TEMPORARY TABLESPACE "TEMP";
CREATE USER johndoe IDENTIFIED BY johndoe
* ERROR at line 1: ORA-65096: invalid common user or role name
SQL> alter session set container=PDBORCL;
Session altered.
SQL> CREATE USER johndoe IDENTIFIED BY johndoe
2 DEFAULT TABLESPACE "USERS"
3 TEMPORARY TABLESPACE "TEMP";
User created.
SQL> GRANT CREATE SESSION TO johndoe;
Grant succeeded.
SQL> connect johndoe/johndoe ERROR: ORA-01017: invalid
username/password; logon denied
Warning: You are no longer connected to ORACLE. SQL>
Can Anyone please help?
connect johndoe/johndoe
This is wrong, you need to specify the pluggable database PDBORCL.
connect johndoe#pdborcl/johndoe
Here is a test case to prove,
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> alter session set container=PDBORCL;
Session altered.
SQL> create user test identified by test;
User created.
SQL> grant create session to test;
Grant succeeded.
SQL> connect test#pdborcl/test;
Connected.
SQL>
You can have a look at Mandatory steps post 12c installation for common issues post 12c installation.

Resources