Teradata - Create views of tables in another database - teradata

I need to create in Teradata VIEWS of tables in another database.
I have created both but now when making a select of the VIEW, It shows me the following Error: "Table/View 'MyDatabase.MyView' not found, or you have no access rights".
What type of rights need the User, View, Table, Database... to make this works? And at what time and how should I give them?
Thanks!

Suppose we have SomeDB.TableOrViewA and a view MyViews.ViewX that references SomeDB.TableOrViewA. The "view owner" MyViews is allowed to provide access (via ViewX) only if MyViews holds corresponding rights WITH GRANT OPTION.
In order for a UserN (who is not the creator of MyViews.ViewX) to SELECT from the view, not only must UserN hold SELECT permission on MyViews.ViewX (or the entire MyViews database), but the MyViews database must also hold SELECT WITH GRANT OPTION permission on SomeDB.TableOrViewA or on the entire SomeDB database. This is true whether or not UserN has SELECT permission on the underlying SomeDB.TableOrViewA itself.
GRANT SELECT ON SomeDB.TableOrViewA TO MyViews WITH GRANT OPTION;
or GRANT SELECT ON SomeDB TO MyViews WITH GRANT OPTION;

Related

Unable to access user_tables table in oracle

I am new to oracle. I have created the user axsaum in DB and logged in as the same user. When I try to access
select * from user_tables or dba_tables
its throwing error as table not exist
Please suggest me why i dont have privilege to access default tables?
how to access those?
SQL> select * from user_tables;
* ERROR at line 1: ORA-00942: table or view does not exist
SQL> select * from dba_tables;
* ERROR at line 1: ORA-00942: table or view does not exist
I think you need to give previliages to newly created user
you can use grant for giving permission to user
once permission given you can see tables as well as can perfrom DML and DDL on DB
for gratting previliages
for all permissions you can use
GRANT DBA TO axsaum ;
For other permissions you use below
GRANT CONNECT TO axsaum ;
GRANT SELECT ANY TABLE to axsaum
is a system privilege grant that allows user to select from any Table or View.
GRANT SELECT on some_table to axsaum
is an object privilege grant that allows user to select from Table.
GRANT SELECT, UPDATE ON some_table TO axsaum;

External Table via DBLINK

I am trying to select a set of data on external table via DBLINK. I am getting, however, this error:
ORA-06564: object MY_EXTERNAL_DIR does not exist ORA-02063: preceding line from foo
foo is my remote database link. And no, there is no directory on that disc.. This directory is located on the remote db.
I have created a VIEW on local DB and tried to access it remotely, but it didn 't help.
Am I wasting my time?
Thank you.
I have tested this and it is possible to access an external table over a database link. I think that you will need to grant read and write permissions on the (oracle database object) directory to the user that you are connecting the db link to if this isn't the user that owns the external table.
Assuming that you have a user bob that owns a working external table called ext_tab in the xtern_data_dir directory on a remote database dbr and you want to access that table via the remote user jim
CREATE USER jim IDENTIFIED BY "passwd";
GRANT CREATE SESSION to jim;
GRANT SELECT ON bob.ext_tab TO jim;
GRANT READ, WRITE ON DIRECTORY xtern_data_dir TO jim;
On the local database create the db link to jim to dbr
CREATE DATABASE LINK dbr CONNECT TO jim IDENTIFIED BY "passwd" USING 'DBR';
Now the select will work
SELECT * FROM bob.ext_tab#DBR;
#Lunc, thank you!
I was almost sure that it was impossible to reach an external table remotely. Until your post! :)
I 've managed to select my data, this one helped.
GRANT ALL ON DIRECTORY MY_DIRECOTY TO PUBLIC;

Unable to create REFRESH FAST ON DEMAND materialized view

I have two database HB and DSHB. I am trying to create REFRESH FAST ON DEMAND materialized view in DSHB schema wherein HB is remote schema using dblink with following code,
CREATE materialized view MV_HB_SYSTEM
BUILD IMMEDIATE
REFRESH FAST
ON DEMAND
WITH PRIMARY KEY
AS
SELECT DELETED, SYS_NO FROM HB.HB_SYSTEM#HBLINK;
But getting following error in creation,
SQL Error: ORA-12018: following error encountered during code generation for "HB"."MV_HB_SYSTEM"
ORA-00942: table or view does not exist
But on running query " SELECT DELETED, SYS_NO FROM HB.HB_SYSTEM#HBLINK;" in separate connection works perfectly.
I have also created Materialized View Log with following code,
CREATE Materialized View Log ON HB_SYSTEM;
I have found in some forum that SELECT privilege on Materialized View Log needs to be granted as mentioned below,
GRANT SELECT ON MLOG$_<tableName> to DSHB;
where DSHB is the account that will accessing the log (ie via the db link).
But when i run this command from HB schema i am getting error stating DSHB user or role is unavailable in HB and i am unable to grant SELECT on Materialized View Log in HB schema. Is it possible to directly grant SELECT privilege to dblink from remote schema? i mean something like below query from HB schema. I tried but didnt work.
GRANT SELECT ON MLOG$_<tableName> to HB.HB_SYSTEM#HBLINK;
Please suggest how to resolve ORA-00942 error and create REFRESH FAST ON DEMAND materialized view.

ORA-22285: non-existent directory or file for FILEOPEN operation

I am trying to insert code of XML file into a column which is of XMLtype
I have below query which is working fine
select extract(xmlcol,'/*')
from (SELECT xmltype(BFILENAME('MEDIA_DIR', 'xmldata1.xml'),nls_charset_id('UTF-8')) xmlcol FROM dual)
On running this query I am getting the Xmlcode inside the xml file(xmldata1) in one row.
Now, As per my requirement I have created a type which reads data from the XMLfile.
Below is the code of member function of the type:
create or replace type body t_emp
as
member function get_xml return xmltype is
v_xml xmltype;
begin
select extract(xmlcol,'/*') into v_xml
from (SELECT xmltype(BFILENAME('MEDIA_DIR', 'xmldata1.xml'),nls_charset_id('UTF-8')) xmlcol FROM dual);
return v_xml;
end get_xml;
end;
I am calling this type member function in my code. Below is the code
declare
t_emp1 t_emp;
r1 xmltype;
begin
t_emp1 := t_emp(2);
r1 := t_emp1.get_xml;
insert into EMPLOYEE_XML values (t_emp1.id,r1);
end;
Here variable r1 is of importance as I am fetching XML data in this variable.
On running this code I am getting below error:
ORA-22285: non-existent directory or file for FILEOPEN operation
I am not able to understand why this error is coming as the directory exist. I am able to run previously mentioned SQL query.
Thanks!!
The user you are creating the type as only has permissions on the directory object granted through a role. Privileges from roles are not inherited by stored PL/SQL blocks by default. When you run the SQL directly the role is enabled; when you run in through the PL/SQL member function the role is disabled and the directory is not visible to your user. You need the directory privileges to be granted directly to your user.
In your case you are working in the SYSTEM schema (so the directory privilege is coming via the EXP_FULL_DATABASE role, which comes from DBA), which is a bad idea; it is not good practice to create objects in that schema (or any built-in schema), so granting privileges directly to `SYSTEM would also be a mistake here.
You should create a new user/schema, with the minimum privileges it needs. You've already created the directory object, so the new user set-up would include:
grant read,write on media_dir to your_new_user;
You can then create the type and its member function in that new schema, and you'll be able to execute it from your anonymous block.
If you can only have privileges granted through a role then you could instead change the type declaration to use invoker's rights
create or replace type t_emp authid current_user as object ...
That would even work in your current scenario, sticking with SYSTEM; but again you really shouldn't be working in that schema.

Permission error when trying to add or edit addresses (e.g. Customer Address)

I am trying to do some development to the LogisticsPostalAddress form that is used on forms where an address is modified/added. When trying to add an address (e.g. to an existing Customer) I get the error.
You are not authorized to access table ‘Shipping carrier’ (ShipCarrierAddress). Contact your system administrator.
I have scoured the user permissions and cannot find a way to give permission to this table. I would think that adding an address is a basic function, so can not figure out why I can't.
Thanks,
Kevin
What role is your user assign to? Are you sure users in that role should be able to add addresses to the customer? If yes, here is how you can add permissions to the ShipCarrierAddress table:
With admin user, open development envionrment (Ctrl + Shift + W from
running Ax, or run "ax32.exe -development" from command prompt)
In the AOT, go to Security > Roles. Find the role your user is assigned to.
Exapand the Role > Permissions > Table, add new table and set table name to ShipCarrierAddress and EffectiveAccess (in your case
you want to insert, thus set to Create)
Save the role, and compile the role (not sure if compile is mandatory)
Start a new Ax instance with the user with limited permissions and verify you have access.
I turned out it was an issue with the installation of the lab.

Resources