Oracle does not allow to create "USER" table - oracle

Oracle is not allowing to create USER table.
Can anyone guide me to create USER table in Oracle.?
TIA.

Can you use a different name like my_user or something else. If you are insistent about using the table name user then you will have to provide the table name in quotes.
CREATE TABLE "USER"
(
col1 NUMBER(10)
)
You, will have to use quotes and maintain the upper case when doing any operations on this table.
The following will give you an error.
select * from USER;
ORA-00903: invalid table name
However, the following will work.
select * from "USER";
That said I don't recommend this option and it would be good if you can change your table name.

USER is a reserved keyword in oracle. Thus it can't be used directly.
Here is the list of restricted keywords a.k.a reserved words.
e.g. you can't either create a table called TABLE...

Related

Using oracle seq generator in Informatica Mapping [duplicate]

I use SQL developer and i made a connection to my database with the system user, after I created a user and made a another connection with that user with all needed privileges.
But when I try to proceed following I get the SQL Error
ORA-00942 table or view does not exist.:
INSERT INTO customer (c_id,name,surname) VALUES ('1','Micheal','Jackson')
Because this post is the top one found on stackoverflow when searching for "ORA-00942: table or view does not exist insert", I want to mention another possible cause of this error (at least in Oracle 12c): a table uses a sequence to set a default value and the user executing the insert query does not have select privilege on the sequence. This was my problem and it took me an unnecessarily long time to figure it out.
To reproduce the problem, execute the following SQL as user1:
create sequence seq_customer_id;
create table customer (
c_id number(10) default seq_customer_id.nextval primary key,
name varchar(100) not null,
surname varchar(100) not null
);
grant select, insert, update, delete on customer to user2;
Then, execute this insert statement as user2:
insert into user1.customer (name,surname) values ('michael','jackson');
The result will be "ORA-00942: table or view does not exist" even though user2 does have insert and select privileges on user1.customer table and is correctly prefixing the table with the schema owner name. To avoid the problem, you must grant select privilege on the sequence:
grant select on seq_customer_id to user2;
Either the user doesn't have privileges needed to see the table, the table doesn't exist or you are running the query in the wrong schema
Does the table exist?
select owner,
object_name
from dba_objects
where object_name = any ('CUSTOMER','customer');
What privileges did you grant?
grant select, insert on customer to user;
Are you running the query against the owner from the first query?
Case sensitive Tables (table names created with double-quotes) can throw this same error as well. See this answer for more information.
Simply wrap the table in double quotes:
INSERT INTO "customer" (c_id,name,surname) VALUES ('1','Micheal','Jackson')
You cannot directly access the table with the name 'customer'. Either it should be 'user1.customer' or create a synonym 'customer' for user2 pointing to 'user1.customer'. hope this helps..
Here is an answer: http://www.dba-oracle.com/concepts/synonyms.htm
An Oracle synonym basically allows you to create a pointer to an object that exists somewhere else. You need Oracle synonyms because when you are logged into Oracle, it looks for all objects you are querying in your schema (account). If they are not there, it will give you an error telling you that they do not exist.
I am using Oracle Database and i had same problem. Eventually i found ORACLE DB is converting all the metadata (table/sp/view/trigger) in upper case.
And i was trying how i wrote table name (myTempTable) in sql whereas it expect how it store table name in databsae (MYTEMPTABLE). Also same applicable on column name.
It is quite common problem with developer whoever used sql and now jumped into ORACLE DB.
in my case when i used asp.net core app i had a mistake in my sql query. If your database contains many schemas, you have to write schema_name before table_name, like:
Select * from SCHEMA_NAME.TABLE_NAME...
i hope it will helpful.

How to configure jenkins to choose the schema by default?

I get the a query file and commit it but I have to choose the schema before it, to not get the following error; do you have any idea how to do it?
Thanks for your interest.
INSERT INTO LEAD_ACTV_CONFIG (
*
ERROR at line 1:
ORA-00942: table or view does not exist
I don't know jenkins so I hope the following makes sense. Sorry if it does not.
In order for INSERT to work, you must be connected to a database (i.e. one of its users). That user should contain LEAD_ACTV_CONFIG table, or it must be available to it (which means that some other user, who owns it, has granted the current user access privileges).
Now, if LEAD_ACTV_CONFIG is your own table, then your INSERT INTO would work properly; you don't need any additional privileges as you own the table so you can do anything with it.
If it is someone else's table, then either precede table name with owner name, such as INSERT INTO littlefoot.lead_actv_config (as if I own it), or create a synonym for that table in your schema:
create synonym lead_actv_config for littlefoot.lead_actv_config;
and access it just as you've posted in your question: insert into lead_actv_config

The different between TABLE_NAME vs "TABLE_NAME" in Oracle?

I'm a very new Oracle SQL user and I got a problem.
If I create a table with code such as
create table TBL_NAME...
after that I can get data by
select * from TBL_NAME;
However, when I create table with Navicat (just click on button new table), then I have to add "" to table name to access my table, such as:
select * from "TBL_NAME";
So, is there have other type of table? And if I use Navicat to create table, what type of it?
When you specify the name of a table in Oracle without double quotes then Oracle converts that table name to uppercase. But if you specify the name of the table within double-quotes then Oracle will respect the lower-case letters that you may have.
So, as in your example the name of your table is already all upper-case, then there is no difference in specifying or not the double-quotes.
But for example if you create a table like this:
CREATE TABLE "my_table" ....
Then you cannot access it like this:
SELECT * FROM my_table;
as Oracle will convert that select to this:
SELECT * FROM MY_TABLE;
And there is no such table in your system.
In your case with Navicat, it just needs you to specify the name of the table as-is, but don't worry, just put the double-quotes and stick to all upper-case names and you will be fine.

How to create new schema and list all schema name in oracle

I want to create one new schema in oracle and I used sample code, which is available here
CREATE SCHEMA AUTHORIZATION oe
CREATE TABLE new_product
(color VARCHAR2(10) PRIMARY KEY, quantity NUMBER)
CREATE VIEW new_product_view
AS SELECT color, quantity FROM new_product WHERE color = 'RED'
GRANT select ON new_product_view TO scott
/
But, getting error
ERROR at line 1:
ORA-02421: missing or invalid schema authorization identifier
Also, Please help me how to list name of all available schema. I am using
select username from dba_users;
to list schema, but i think, its not a right approach, because, user and schema has many-to-many relation,which means I can't get all schema name here.
Please help me !!
From oracle documentation:
This statement does not actually create a schema. Oracle Database
automatically creates a schema when you create a user
So you first need to create a User with the schema name
As for your query it's fine, since username list is equal to schema names unavailable
UPDATE: I can't really test it now, but should be something like this:
CREATE USER oe IDENTIFIED BY oePSWRD;
CREATE SCHEMA AUTHORIZATION oe
CREATE TABLE new_product
(color VARCHAR2(10) PRIMARY KEY, quantity NUMBER)
CREATE VIEW new_product_view
AS SELECT color, quantity FROM new_product WHERE color = 'RED'
GRANT select ON new_product_view TO scott;
From the docs: http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_6014.htm
The schema name must be the same as your Oracle Database username.
Do you want to find all users, or all users for which a table (for example) exists? If the latter then ...
select distinct
owner
from
dba_tables
where
owner not in ('SYS','SYSTEM')
Add in other usernames that you're not interested in listing as required.

Drop Database called "User" from Oracle

Ok this is what happend...
One of my colleges run a script that created some tables which included one table called "User" on an Oracle XE 10g. Now we are unable to drop that table, we get an ORA-00903 every time we run a:
DROP TABLE USER CASCADE CONSTRAINTS
The same happens when ever we try to run any alter query on it (that means renaming doesn't work)
Do someone know how to deal with this?
have you tried fully qualifying with quotes:
drop table "myschema"."user"
Randy is right suggesting quoted identifiers. Note however that quoted identifiers are case-sensitive.
First, query ALL_TABLES or USER_TABLES to find the case-sensitive name of that table, and use that name in a statement such as
DROP TABLE "User";
or
ALTER TABLE "User" RENAME TO TBL_USERS;

Resources