Query driving a view and actual view not returning same results - sql

I have a view that is returning four columns of data to be pushed to an external program. When I simply query the view ("Select * from schema.view_name") I get 10353 rows. When I run the actual SQL that created the view (I literally copied and pasted what Oracle had stored, minus the "Create or Replace" statement), I get 238745 rows.
Any ideas why this might occur?

Best guess: when you run the query standalone you're not running it in the same schema the view was created in (I am inferring this from the fact that you included the schema name in your example SELECT). The schema where you're running the query either has its own table with the same name as one of the base tables in the view, or one of the names is a synonym pointing to yet another view that contains only a subset of the rows in the underlying table.

Related

Where used list in BigQuery

I have a view, Wanted to check what sort of SQL can help to identify list of all views and Stored procedure using it.
For Example,
View A is being used in View B, View C and Stored Procedure D.
Is there any metadata schema which can help writing such query where we can track all dependent objects of a certain object in BigQuery. Please assist.
For Example,
View A is being used in View B, View C and Stored Procedure D.
Is there any metadata schema which can help writing such query where we can track all dependent objects of a certain object in BigQuery. Please assist.
You can run the following query that will list all views, this can be done on an individual dataset basis. Of course if you have a set of datasets you could create one UNION ALL query for each dataset to combine the results.
SELECT * FROM dataset_name.INFORMATION_SCHEMA.VIEWS WHERE
REGEXP_CONTAINS(view_definition, 'dataset_name.table_name')
Replacing dataset_name and table_name in the above query.
view_definition in the schema table contains the actual SQL code to create the view. So we are essentially just searching that field for the table name, same would work if you are looking for a view being used in a view.

How to set up a view that replaces a table once processed?

Every time I attempt to save a view that has "create or replace table" I get the error:Only SELECT statements are allowed in view queries.
I am using standard SQL in Google Cloud Big Query. I do not want the view as a scheduled query and the view is too large to run, meaning it errors out asking for me to create a table that allows large results. I want the query to update its associated table every time it is run. I came across the Write_Truncate syntax, however I do not know to use it.
create or replace table.test1 as( all my other queries)
I just expect for big query to allow me to run the table.

Business Object : Replace all not changing schema name in sap Bo universe

We are using Sap BO 3.1 R. We have one exciting universe and pointing the schema name of table to another database.
I tried using replace all option but it's not replacing schema name of one joining condition of table. When am pulling columns in webi I can see old schema name with table name in where clause when it's joining two tables with sub query.
Am not sure where to find that joining condition in universe.as universe is big.I tried with find option but not getting anything.I can see it in PDF format in joins list.
E.g if it's ABC.employee. Am trying to change it to ABC_x.employee
That does sound exciting.
Don't use find/replace. Click-and-drag to select all the tables that need to change (or hit Ctrl-A to select all). Right-click on one of the tables and click Rename Table. Enter the new schema name in Owner, then click OK.

Hive view has no path?

I've tried to make a Hive view so we can start sqooping on the columns we need.
The statement used to create the view:
CREATE VIEW new_view (col1, col2, col3)
AS SELECT col1, col2, col3 FROM source_table;
However the view has no perceived location within our Hadoop cluster. What's odd if we run a SELECT * FROM new_view; we get the data.
But when we try to run an Oozie job to hook into the view we get a table not found error. The table isn't in file browser either.
Reason why you are getting this error is that your view doesn't have any HDFS location to it. Sqoop export looks for export-dir but since your view don't contain any location to it, you are getting this error.
A view is just a layer of abstraction on top of your Hive table (which redirects to HDFS location associated to it). Please find below view definition:
A VIEW statement lets you create a shorthand abbreviation for a more
complicated query.The base query can involve joins, expressions,
reordered columns, column aliases,and other SQL features that can make
a query hard to understand or maintain.It is purely a logical
construct (an alias for a query) with no physical data behind it.
You may have to use the source_table for sqoop-export.
Note that a view is a purely logical object with no associated storage.
When a query references a view, the view's definition is evaluated in order to produce a set of rows for further processing by the query.
You can consider reading :- https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Create/Drop/AlterView
So you might think of storing the view data in a table in order to access it from oozie.

vb.net query for creating table

I have Access as my back end. Student is the database name and its path is c:\Project\student.mdb
And am having few tables in it. When i click a command button in vb.net a new table must be created in the path mentioned. And it should have the fields I declare.
What s the query I need to use ? Is it possible to do like that ?
Yes, it's possible, you can check out the syntax for the create table command.
However, I have to say that creating tables dynamically suggests a bad database design. The database layout should normally remain the same whatever data you put in the database.
If you create tables dynamically, that means that you have data in the table names, but data should go inside the tables, not in table names (or even field names).
Yes it's possible . Just pass the create table command as query and the table name as variable , which you want to add dynamically. for reference of create table command
Create table command