Using Oracle "Create User" command does not automatically create an associated schema - oracle

I'm just getting started with Oracle data export and import and things worked perfectly fine the first time around. But then I came back next day repeated the exact same steps on the same systems, but get ORA-01435: user does not exist error.
System Specs for all machines:
-OS: Windows 2012 R2 x64
-Oracle Server: Oracle 11G Express x64
Objective:
I'm exporting data from Oracle server 1 and importing to Oracle server 2.
Procedure:
Export data dump is successful from Oracle server 1.
but when importing the data dump on Oracle server 2, I follow this procedure:
-Stop IIS service
net stop WAS
Create Schema/user account and Grant privileges before import
net stop WAS
sqlplus / as sysdba;
CREATE user PIE1 identified by PASS1;
GRANT ALL PRIVILEGES TO PIE1;
GRANT IMP_FULL_DATABASE TO PIE1;
According to oracle, all goes well, but look at the first image bellow. In DBeaver, I can see that only the User account PIE1 has been created, but NO schema.
Oracle issue 1. User account created, but not the Schema
Question 1: According to Oracle, the command "Create User" IS supposed to also create an associated Schema. Anyone have an idea why this is no longer working for me? It worked once the night before.
I then continue the import procedure as follows:
imp PIE1/PASS1#xe file=c:\Backups\AVUSER2_6_7.dmp log=c:\Backups\import.log fromuser=AVUSER2_6_7 touser=PIE1;
But get the following error:
Oracle claims the User doesn't exist even though it does
Oracle claims the User doesn't exist even though it does. I repeated the entire procedure and even created an identical import/export user account and credentials, and this error still comes up.
Question 2: Any idea why Oracle "Can't find" a user account that's clearly in the database?
Additional Info:
Checked that my windows account is in admin group
Checked that my windows account is in ORA_DBA group
Opened all CMD prompt as Admin

As you implied, users and schemas as the same in Oracle, you can't have a user without a schema. No idea about DBeaver, but as there are other users that aren't listed under 'schemas' (according to your second image - ANONYMOUS, DIP, ...) that seems to be unrelated.
(Purely a guess, but perhaps the user you're connect as in DBeaver just doesn't have visibility of any objects owned by those users - maybe it only lists users it can see in all_objects, say. Pure speculation, but you could investigate that by looking at the data dictionary while connect through SQL*Plus as the same user. According to this old forum post, there is an option to hide empty schemas...)
The import is connecting successfully as PIE1 - you'd get a different error, ORA-01017, if it wasn't and you wouldn't see the 'Connected to...' banner or anything after that.
Your import command has a trailing semicolon that should not be there. The "importing ... objects into" message shows that it's trying to import into the PIE1; user and not the one you actually created, PIE1. Remove that semicolon and try again.
Incidentally, you can probably also remove the #xe TNS alias and stick to a local connection, assuming the environment is configured as it was whenyou ran SQL*Plus. You should also consider using datapump expdp/impdp rather than the legacy exp/imp.

Related

How to solve ORA-65096 from Oracle SQL Developer?

I am trying to create a new user from Oracle SQL Developer. I made a connection with the user Sys and the password that I entered in the installation of Oracle Database XE 18c.
When creating the user I get the error ORA-65096, I have searched the internet and the solution I found is to write the following:
alter session set "_ORACLE_SCRIPT" = true;
However, I want to know if it is possible to create the new user without using any SQL statement or script and do it from the Oracle SQL Developer interface, do I have to login with a different user than Sys to create a new user? or what do I have to do? Could someone give me a detailed explanation please. I am learning how to use this database and I want to try to understand what I am doing.
oerr ora 65096
65096, 00000, "invalid common user or role name"
// *Cause: An attempt was made to create a common user or role with a name
// that was not valid for common users or roles. In addition to >the
// usual rules for user and role names, common user and role names
// must consist only of ASCII characters, and must contain the >prefix
// specified in common_user_prefix parameter.
// *Action: Specify a valid common user or role name.
This implies that you are connected to the root container instead of to a regular plug in database (pdb) where applications should be built. The solution for you is not to overrule setting to enable building an application in the root container but to connect to the pdb that has been made to host your application.
you can check the available pdb's by viewing v$pdbs. The special pdb cdb$root is as the name already tries to tell, the root container. show PDBS will give similar output.
Using alter session set container = [pdb_name]; can be used to switch to your container of choice where regular rules apply.
Even better is to directly connect to that pdb using sqlnet.

Oracle 18 xe weirdness - can't login as new user

I'm getting reacquainted with Oracle after several years and Oracle 18 XE is causing some problems. I use SQLDeveloper to connect as the SYSTEM user. Then when I create a new user cpp it says that is an invalid user name. I have to prefix new users with c##, so I created the user c##cpp. The c##cpp user is there under Other Users.
But when I try to create a new connection as the c##cpp user the connection fails. I've also tried creating the connection as just cpp, but that fails too.
What's up with creating users in Oracle 18 XE?
-------Update showing my connection parameters-------
I get the same error if I try to connect with SID XE.
Welcome back to Oracle.
Since you've been away, we added a Multitenant architecture. There is a Container Database - it has common users, with names like C##user.
What you're looking for is the actual database where your data is going to live, that's called a pluggable database. There you would go back to creating users, just like you did back before you left.
Make sure you connect to the pluggable database service. The default would be 'XEPDB1' - connect to THAT as sys or system, and then create your users.
It looks like the problem is that Oracle doesn't like lower case user names. When I put the username in double quotes the connection succeeds:
This is on Oracle 11. I gave up on Oracle 18 XE and installed Oracle 11. What a ridiculous waste of time.

Oracle SQL Developer - Data Miner Repo - Task failed

I've been fighting against oracle sql developer for about two days and I just can't get the thing to work.
I would like to learn more about data mining and take a look at their examples and work threw their tutorials, but I cant even get the thing setup.
What I did:
Installed Oracle 12_1 database + oracle_examples.
I then created an administrator account via the oracle sql developer.
connection name: admin
username: sys
password: password
Role: sysdba
SID: orcl
Everything else was left as it is.
I then had to install all the example .sql files manually.
I followed the guide from here: Oracle Install Example Schemas
I did everything exactly the same as the guide told me to do, except I had to do this "hack" command which allowed me to create users. Else I would always get the
ORA-65096: invalid common user or role name
alter session set "_oracle_script"=true;
The new users now show up in every connection that I create in my SQL Developer under "other users". (HR, OE, etc..)
Now I created a new user "dmuser" like the guide told me to do here: (yes - with sql plus)
Oracle create a datamining user
Now I wanted to install the data miner repo. Which should be very easy:
Tools, data miner, make visible. And the data miner window showed up. I then added my dmuser connection, double click dmuser to install the data miner repository. I then press start to install the repo and then it says "Task Failed" with the MOST useless error message I have ever seen:
anonymous block completed
anonymous block completed
Drop public synonyms created by ODMRSYS.
anonymous block completed
anonymous block completed Total Number of Objects: 0
Total Number of Objects Dropped: 0
Total Number of Objects Failed to Drop: 0
Can anyone help me resolve this issue? My guess would be that the "hack" command which I used to create all the users messed something up, but I'm not sure. I'm very new to Oracle, so I have no idea what I'm actually doing here, so please have some mercy on me.
Thanks in advance.
Hope someone can fix this mess.
Aight, be prepared for a complicated answer...
Sql developer exectues a .sql file to install the data miner repo.
The sql is named "installodmr.sql". Found the info here:
Install repo by script
I had a look at the script and what it does. It opens more scripts which insert tables, and users and grant privileges etc...
The problem why the script would not execute correctly was due to a couple of reasons.
1) As mentioned in my question, I can't just create a user, I have to type the command:
alter session set "_oracle_script"=true
The script calls other scripts that then want to create user, which in my case was not allowed and caused the ORA-65096 error.
So I had to insert the alter ... command before the script called another .sql file.
2) The path to the .sql files was not correctly set and it could not find the files which caused problems. They where referenced like this:
##file.sql
I changed it to the direct path:
#C:\Oracle\product\12.1.0\home\sqldeveloper\dataminer\scripts\file.sql
I let the script run and it worked.
Now data miner repo is installed.
Wuhey! :)

Pl-Sql User Connection

I've been starting oracle on my job. But i've been using MS all the time. Now i have problem on User-Shema structure. I tryed a create table with sql query, but table had been created in somewhere else then i wanted. (I've already created a user named LPA) I just wrote the query, and table is in the (GeneralDatabase) Tablespaces->Users->(Here). I want to create a table in LPA schema, under the table folder. I've been searching for it but i could'nt get it. So need some help please.
PS:I found that i need to connect with user, than write to query with TS_LPA(Thats my tablespace). But i also cant connect with the user LPA.(We can say this is my first problem)
In Oracle there is no "dbo" or default schema, in case that is what you are looking for. You must specify the target user account when you connect (log in) to the database, and that account will be used as the default schema for all of your subsequent actions. (This is similar to a home directory in Linux, where if I log in as williamr and create a file, it will belong to williamr and not some generic default account.)
In your case I suspect you are connecting as SYS or similar, in which case your table now belongs to SYS (or whoever you are connected as). You'll need to drop it and try again.
If you don't want to post the connect string you used to connect initially for some reason, then execute the following query to see your current schema:
select user, sys_context('userenv','current_schema') from dual;
(Normally user and sys_context('userenv','current_schema') will be the same, but worth double-checking.)
In PL/SQL Developer you can only issue connect commands from a Command window (not a SQL window). Alternatively you can use the 'log on' menu tool, or Session > Set Main Connection from the menu, or (best if you want to reuse it later) Tools > Define Connections, which has a 'Test...' button to validate a new connection. You'll need the username, password and database service name (not just username and password).
connect with LPA user.
specify the schema name before table name.
create table LPA.tbl_name(col1 datatype1,....);

Create database in oracle for manually created user

I want to create the user and the database within that user. But when I tried to create database its giving the warning message as
ERROR at line 1:
ORA-01501: CREATE DATABASE failed
ORA-01100: database already mounted
Then I tried
STARTUP NOMOUNT;
Its giving the warning message for insufficient privileges even I have given all the permission to that particular user.
Can any one please help in finding the solution for this?
You don't create a database under a user in Oracle; I believe you're using terminology from another database poduct. The equivalent is a schema, which is a logical container for a group of objects. User and schema are essenentially synonymous in Oracle - when you create a user is automatically has its own schema.
You create the database once (which you already seem to have done, or had done for you), then create as many schemas/users as your application needs. You don't ever rerun the create database under normal circumstances - you certainly wouldn't as a normal user.
If you connect as that user you will be able to create tables, views, packages etc., assuming it has really been granted all the necessary privileges.

Resources