Hive - HUE - cannot create materialized view - hive

when i try creating a materialized view in a HIVE db through HUE i get the following :
Error while compiling statement: FAILED: ParseException line 1:88 cannot recognize input near 'CREATE' 'MATERIALIZED' 'VIEW' in ddl statement
the query is simple, like :
CREATE MATERIALIZED VIEW name AS
select * from table;
yet it doesn't work, can someone help me please?
Thanks

Related

Materialized view in Marketing Performance DB in Azure SQL database

I want to create a materialized view in a marketing performance database but am getting an error while trying to create .
Using below query to create
CREATE MATERIALIZED VIEW InvoicesTempM
WITH (distribution = hash(Invoiceid), FOR_APPEND)
AS
SELECT Invoiceid, COMPANY from dbo.Invoices
Getting error as below:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'CREATE MATERIALIZED VIEW'.
Completion time: 2023-02-09T10:23:12.8418869+05:30
Could anyone help here how can we create materialized view in Azure SQL database, if we cannot please share if there is any alternatives?
MATERIALIZED VIEW are a concept invented by Oracle. The closest topic in Microsoft SQL Server are INDEXED VIEW, that is :
a classical view with some limits and the SCHEMABINDING option
a UNIQUE CLUSTERED index that is created on the view.
In MS SQL Server all Indexed Views are alwyas synchronized with source data (do not need to refresh).
Refer to "Create indexed views"

SQL Error: ORA-01732: data manipulation operation not legal on this view

I am using oracle 10g and sql developer for writing queries.
I have a user ESTRADM and it has some tables and some Materialized Views . I am trying to insert a row into an table MTEP_THREEDS_CARD_MASTER and its respective Materialized view is MTEP_THREEDS_CARD_MASTER (both table and view has same name).
Now when I execute query
insert into ESTRADM.MTEP_THREEDS_CARD_MASTER values (col1,col2,..);
it gives me an error:
Error report:
SQL Error: ORA-01732: data manipulation operation not legal on this view
01732. 00000 - "data manipulation operation not legal on this view"
*Cause:
*Action:
My Materialized view has QUERY REWRITE DISABLED.
I didn't get this why it is trying to insert into the view why it is not writing into the table ?
How can i insert a row into the table ?
Only a subset of materialised views can be directly modified, and in order to be so they must adhere to strist rules laid out in the documentation: http://docs.oracle.com/cd/B19306_01/server.102/b14226/repmview.htm
If your MV definition meets these restrictions and is still not modifiable then post the definition of the MV and the complete definitions, including constraints, of all of the tables that it references.

Create view and use it in a single SQL script

Simple thing ... i thought. Create a view and use it later in the same SQL script.
Let's say we have a script as follows:
CREATE VIEW someView AS (...)
DROP VIEW someView
If I try to parse it SQL Management complaints there's an error around DROP.
If I execute them separately (create first, then drop) they work both fine.
Is there any way to create a view and use it in a single SQL script?
I could wrap further statements in string an then EXEC it but it's a bit inconvenient.
Code example was fixed (missing VIEW)
More meaningful example:
create view TEST as (select name from spt_values where number=1);
drop view TEST
Is it possible to execute it at once?
I got the error:
Msg 156, Level 15, State 1, Procedure TEST, Line 2
Incorrect syntax near the keyword 'drop'.
Running create statement separately and then dropping view works perfectly.
Separate your query with GO keyword like query bellow:
CREATE VIEW someView AS ()
GO
DROP VIEW someView
GO
Regardless of which particular DBMS you are using, you should create a script separating your SQL statements with ';'.
For example
CREATE VIEW someView as (...);
<<some other sql statements>>
DROP VIEW someView;

PhpPgAdmin Syntax error when creating View

I am attempting to create a View in PhpPgAdmin (PostGreSQL db) which has the following SQL statement:
DELETE FROM myTable WHERE myTable.error IS NULL;
PhpPgAdmin gives me the following error:
ERROR: syntax error at or near "DELETE" at character 59
In statement:
CREATE OR REPLACE VIEW "Schema1"."Delete empty errors" AS DELETE FROM myTable WHERE myTable.error IS NULL;
As far as I can tell this SQL statement is valid, and I have delete privileges for the table. Is the DELETE statement not allowed in Views? Any ideas what I am doing wrong?
Views are used to display the data from SELECT statements only (usually when the SELECT is complex). Views cannot contain DELETES, UPDATES, or INSERTS.
Perhaps you want a function?
EDIT: As OMG Ponies points out, you can have updateable views, but thats where you would issue a DELETE to an existing view and then use a RULE to rewrite the query as a DELETE.
And please, please don't wrap a function call to do a DELETE as a side effect in a view. Its unexpected and Jesus shoots a puppy every time this happens.

CREATE OR REPLACE VIEW sql error

Trying to update a table view using:
CREATE OR REPLACE VIEW [vtable] AS SELECT * FROM Files_Table ORDER BY File
The table is returning the old view, not the updated.
Statement tested in the Sqlite database browser:
Error message from database engine: near "OR": syntax error
but didn't get this in the program?
Any idea why it's not updating?
SQLite does not support the CREATE OR REPLACE syntax. The only database that I know which supports that syntax is Oracle, but I am guessing there are others.
Drop the view and create it with the new definition:
DROP VIEW IF EXISTS [vtable]; -- "OR REPLACE"
CREATE VIEW [vtable] AS SELECT * FROM Files_Table ORDER BY File;
I ran into the same error when using CREATE OR REPLACE in MS SQL Server. The following worked for me:
ALTER VIEW [vtable] AS
SELECT *
FROM Files_Table
ORDER BY File;