This content has been marked as final. Show 3 replies
795291 wrote:I think you are confusing table and view. You created a table based on what AT THE TIME was in table xx_ar_customer. You need a view:
I created a table whose definition is a select query.
Then it will always return you as many rows as there are CURRENTLY in table xx_ar_customer org_id = '87'.
create view xx_customer as select customer_name,customer_number from xx_ar_customer where org_id = '87' /
I cant create view. I tried that before. If i use view then my query runs for a very long time and if i create a table then the run time is reduced by half :)
So if we create Table as a select statement, then will it give data at the point of time it was created?
Will it not give latest data?Not unless the latest data happens to be the same as the data at the time it was created.
CREATE TABLE AS is kind of like putting a photograph of yourself on your web site. If you smile, that doesn't mean the picture smiles.
CREATE VIEW is kind of like hanging a video camea from your hat, and streaming the output to your web page. As soon as you smile, the picture smiles. It's more expensive than a still picture.
A compromise apprioach is a Materialized View , which is really a type of table. Like any other table, it occupies space, and is relatively fast to use. You can define a materialized view to be refreshed at regular intervals (once a day, once an hour, once a week, ...) or whenever there is a change in the base table(s).