0
CREATE MATERIALIZED VIEW Available
REFRESH FORCE
START WITH CURRENT_DATE NEXT CURRENT_DATE + 1
AS
SELECT Table.item_id AS item_id, 
Table.reserv_id AS reserv_id  
FROM Table
LEFT OUTER JOIN Reserv ON Reserv.reserv_id = Table.reserv_id  
WHERE Reserv.start_date > CURRENT_DATE
OR Reserv.end_date < CURRENT_DATE 
OR Table.reserv_id IS NULL;  

I want to create view which is update once a day but I get error: " syntax error at or near "REFRESH" ". What is wrong with it?

1
  • You syntax doesn't seem to be documented. Where did you get the idea from? Commented Jun 16, 2020 at 10:55

1 Answer 1

1

You cannot use any REFRESH clause in PostgreSQL because it does not exist in PostgreSQL.

If the following query is correct in your database:

SELECT Table.item_id AS item_id, 
Table.reserv_id AS reserv_id  
FROM Table
LEFT OUTER JOIN Reserv ON Reserv.reserv_id = Table.reserv_id  
WHERE Reserv.start_date > CURRENT_DATE
OR Reserv.end_date < CURRENT_DATE 
OR Table.reserv_id IS NULL;  

Following statement should work:

    CREATE MATERIALIZED VIEW Available
    AS
    SELECT Table.item_id AS item_id, 
    Table.reserv_id AS reserv_id  
    FROM Table
    LEFT OUTER JOIN Reserv ON Reserv.reserv_id = Table.reserv_id  
    WHERE Reserv.start_date > CURRENT_DATE
    OR Reserv.end_date < CURRENT_DATE 
    OR Table.reserv_id IS NULL;  
Sign up to request clarification or add additional context in comments.

1 Comment

Don't forget to refresh materialized views by event using trigger or by interval using crontab

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.