I tried to create a view in oracle but it shows
"table or view does not exist"
Query :
create or replace view schema1.view1 as select x.id,x.name,y.address from person x, details y where x.id=y.id;
This select query working fine select x.id,x.name,y.address from person x, details y where x.id=y.id;
but can't create view with that
Related
I have table "prod.refrence_type" I create view above it like :
create view s_per.refrence_type as select * from prod.refrence_type ;
then I create view above s_per.refrence_type :
create view s_per.final_type as select * from s_per.refrence_type ;
is there are any way to knew from presto for given table name what is the order of views created ?
the excepted output is :
prod.refrence_type,s_per.refrence_type,s_per.final_type
what I try :
I can get only on the direct view that we build above table using information_schema.views :
SELECT table_catalog,table_schema,table_name,view_owner,regexp_replace(view_definition,'\n',' ') FROM information_schema.views where table_name LIKE '%prod.refrence_type%'
so i can get s_per.refrence_type but i can not get s_per.final_type , is there are any direct way for a given table name to get the views in the orders that they build on presto ?
Is it possible to query object (object being table, view, etc.) status in Postgres? In Oracle an equivalent query would be:
SELECT owner,
object_name,
status
FROM all_objects
WHERE object_type = 'VIEW'
(returns VALID/INVALID in status column)
Please let me know. I've googled for this already, but have not found much.
Michael
https://stackoverflow.com/a/39120069/5315974
Postgres does not let you break the view (RULE), eg:
t=# create table so183 (i int);
CREATE TABLE
t=# create view v183 as select i from so183;
CREATE VIEW
t=# alter table so183 alter COLUMN i type text using i::text;
ERROR: cannot alter type of a column used by a view or rule
DETAIL: rule _RETURN on view v183 depends on column "i"
one of the questions I have to do from school asks me to do the following:
"Create a view called TITLE_UNAVAIL to show the movie titles and media_id of
the media not returned yet. The view should not allow any DML operations. "
This is my script:
CREATE VIEW TITLE_UNAVAIL7
FROM RENTAL_HISTORY7
SELECT title, media_id
WHERE return_date = null
and I get the error saying:
"ORA-00905: missing ketword"
Can someone advise on what I'm doing wrong?
First of all you should read the documentation: CREATE VIEW
CREATE VIEW TITLE_UNAVAIL7 AS
SELECT title, media_id
FROM RENTAL_HISTORY7
WHERE return_date IS null;
This will be the standard answer (as you see form other people). In order to prevent any DML on this view, add WITH READ ONLY, i.e.
CREATE VIEW TITLE_UNAVAIL7 AS
SELECT title, media_id
FROM RENTAL_HISTORY7
WHERE return_date IS null
WITH READ ONLY;
You are not using the right syntax; also, you can not check a column for null values with = null, but you need is null
CREATE VIEW TITLE_UNAVAIL7 AS
SELECT title, media_id
FROM RENTAL_HISTORY7
WHERE return_date is null
I have one table and view where one column is common which is the primary key of the table. Now if I want to join the table and view only with specific columns, should I create view or table in that case? Also I want to import the joined result to Tableau.
Well If you want just join table and view in single query you may write it, or you may create view for it, if you want. For example:
create table tmp_table_a (id, first_col, second_col, third_col) as
select level, lpad('a',level,'b'), lpad('c',level,'d'), lpad('e',level,'f')
from dual connect by level < 101;
create view v_tmp_a as
select id, substr(first_col,1,10) as first_sub_col from tmp_table_a;
simple query:
select second_col, third_col, first_sub_col
from tmp_table_a t1, v_tmp_a v1
where t1.id = v1.id;
or create view:
create view v_join_a as
select second_col, third_col, first_sub_col
from tmp_table_a t1, v_tmp_a v1
where t1.id = v1.id;
select * from v_join_a;
I have created a VIEW by joining some number of tables. I used a SP to call that VIEW and in the SP I'm filtering the data set of the view using an ID. Now I need to pass this ID to VIEW and do the filtering inside the VIEW itself. What is the way of passing this ID as a parameter to view in Oracle 10g?
Current View
CREATE OR REPLACE FORCE VIEW "MY_VIEW"
//SELECT statements goes here
FROM MY_TABLE_1, MY_TABLE_2
//TABLE JOINS
where
//FILTERS
Current Stored Procedure
CREATE OR REPLACE PROCEDURE MY_SP
(
REQUESTACCOUNTID IN NUMBER
, p_cursor out SYS_REFCURSOR
) AS
internal_flag NUMBER;
BEGIN
open p_cursor for
SELECT //SELECT THE COLUMNS
from MY_VIEW my
WHERE my.account_id = REQUESTACCOUNTID;
END MY_SP;
What I need to do is, parse the parameter REQUESTACCOUNTID to the view while selecting
this is sorted out using a package variable. More explanation can be found using this URL