I need to create and drop external tables and im able to do that in non production environment (its used to import massive csv files, so those tables persist only for the duration of the import). However there is no way i can have table create and drop rights on production, so im not sure how to do that on production. How are you solving such problem ?
I can see from documentation that privileges for external tables are a subset of privileges for "normal" tables, while i was hoping there could be a set of privileges for external tables only, which would solve my problem. Is there something like that in newer versions (im using 12c)
from documentation :
System and object privileges for external tables are a subset of those for regular table. Only the following system privileges are applicable to external tables:
CREATE ANY TABLE
ALTER ANY TABLE
DROP ANY TABLE
SELECT ANY TABLE
Related
I am working in an Oracle APEX application and am trying to query tables in another schema (that another Oracle APEX application sits on) to pull in data to my application.
The applications are hosted within the same APEX workspace and on the same Oracle 11g instance. Our application have tables that are structurally the same as the tables we're trying to query in the other schema.
Using the schema prefix (SELECT * FROM "SCHEMA2".TABLE1;) when querying is throwing an error that the tables do not exist (ORA-00942: table or view does not exist)
The second thing I tried is creating a database link between the two schemas, but when trying to establish the connection I'm getting the following error: ORA-01031: insufficient privileges
Can someone identify where I'm going wrong here / help me figure out how to query the other schema?
Database link is used when there are different databases involved; your schemas reside in the same database which means that the first attempt was correct: prefixing table name with its owner, e.g.
SELECT * FROM SCHEMA2.TABLE1
However, first connect as schema2 user and issue
grant select on table1 to schema1;
Otherwise, schema1 can't see the table. If schema1 is supposed to do something else with that table, you'll have to grant additional privileges, such as insert, update, delete, ....
I am using an oracle database. I am accessing that database through two users. They are userA and userB. I have created some tables, packages and procedures etc. in userA schema. Here after I want to continue my work using 'userB' and remove userA.
I granted permissions from userA to userB and created a table with a separate name by selecting all records. Then I saw that triggers and indexes have not been created. I want to know the best method to copy tables, packages and procedures with data from one user to another.
You can copy tables by backing up using expdp and then importing using impdp with the remap_schema/remap_tablespace options (example in this answer).
You cannot use this method for packages, procedures or triggers as the impdp documentation states that:
Restrictions
The mapping may not be 100 percent complete because there are certain schema references that Import is not capable of finding. For example, Import will not find schema references embedded within the body of definitions of types, views, procedures, and packages.
For triggers, REMAP_SCHEMA affects only the trigger owner.
To transfer these you will have to edit the source code of the triggers/pacakages/procedures/etc. and then recompile it on the new schema so that the schema references within the code are also updated.
Our application has its data structured across two schemas, let's call them Main and Archive. This is needed as some tables from the Main schema are archived into corresponding tables in the Archive schema.
The Main schema updates are run using a Liquibase servlet which is run by the Main user when the application first starts.
At the moment all archive updates are run as a separate DBA task. This is a bit inconvenient as we must engage a DBA for simple things like creating a new table in the archive schema and granting the right permissions to the Main user which is the absolute owner of all application data.
We are considering making Main user able to create/alter objects in the archive schema and embed this in our Liquibase scripts.
The Main user has been granted an APP_ADMIN_ROLE that make it entitled to CREATE, ALTER, COMMENT ON etc ANY TABLE so it is able to create and drop tables in the Archive schema.
However, we hit the problem that despite tha fact the Main user can create an Archive table it is not able to grant CRUD operations on that table to itself.
Is there any way to achieve this.
GRANT DBA TO MAIN is not an option.
Thanks in advance
For future references (and extracted from the comment of kfinity), the following solution answered the OPs question best:
A lazy fix: you can also grant CRUD operations for ANY TABLE. In your
case, you could either grant it to the Main user or the role. e.g.
grant select any table, update any table, delete any table, insert any table to APP_ADMIN_ROLE;
I need to create a copy of DDL and Data from an Oracle 12cR1 schema.
I can't use the SYS or other High Privileges user.
I can only use SQL DEVELOPER using the schema credentials.
The rights I have are:
Create and alter object privileges within the schema (such as CREATE
TABLE).
Insert, read, update and delete data privileges on the tables
within the schema.
Execute privileges on the stored procedures,
functions and packages within the schema.
I can use Oracle SQL Developer or other third party tool.
I have used the "Database Export" functions, but I ahve found no way to get both the DDL and the INSERT queries in the correct order. Some table have dependencies, so I need to respect a logic order for both DDL and Queries.
In my opinion, you should use a tool which is designed to do such a task, and that's Data Pump (Export & Import). It requires you to acquire privileges on a directory which resides on the database server, and that's something that a privileged (SYS) user creates and grants. If there's a DBA there, ask them to provide it for you.
If there's none, you can still use the Original EXP utility which creates a DMP file on your own computer.
The advantage of the export is that Oracle handles everything that seems to bother you.
If I were you, I wouldn't do it manually, there's really no need to do it that way. Apart from the fact that it is time-consuming, you'll have to take care about foreign key constraints, create slow INSERT INTO statements ... shortly, don't do it. Use (Data Pump) export and import.
You can disable all the constraints and triggers first, then insert the data. After data loaded, enable them all.
You can also try to use PL/SQL Developer to export the objects first. This tool exports objects in dependency order. Then export the data, but not sure it exports the data in dependency, you can try if there are disable constraints/triggers option when export.
I need some help with vocabulary, I don't use Oracle that often but I am familiar with MySQL and SQL Server.
I have an application I need to upgrade and migrate, and part of the procedure to do that involves exporting to an XML file, allowing the installer to create new database tables, then import to the new database tables from the XML file.
In Oracle, my database connection specifies a username, password, and an SID.
Let's call the SID, "COMPANY-APPS". This SID contains tables belonging to several applications, each of which connects with a different user ( "WIKIUSER", "BUGUSER", "TIMETRACKERUSER" ).
My question is:
Can I re-use the same user to create the new tables ( with the same names ).
In MySQL or SQL Server, I would create a new database and grant my user privileges to create tables in it.
OR, do I need to create a new database user for my upgraded tables?
The word you are looking for is Schema in Oracle. When you create a user they have a schema associated with them, so if I created the user 'Tim' and a table called 'data' then it can be found globally (in that database) as Tim.data