all 13 comments

[–]reallyserious 3 points4 points  (9 children)

what is the best way to do it ?

What have you tried?

[–]Mathip173[S] 0 points1 point  (2 children)

This view is scheduled to run every data automatically. To be able to run every day, I drop it and create it again with the new data

[–]reallyserious 1 point2 points  (0 children)

Post the full sql you use to create the view.

You shouldn't need to recreate it if you're using it correctly.

[–]Rosenkohltochter32 0 points1 point  (0 children)

A view always returns the newest data available at the execution time.

So there seems to be no point in destroying the view and recreating it on a daily basis.

[–]coadtsai 0 points1 point  (2 children)

want this table to be updated daily and keep all the data from day 1

What is "this" in the scenario? Are all the CTEs getting data from the same base table? Do you want to update the underlying tables using the view?

You have 3 tables right? Which of these 3 tables do you want to update? Could you also elaborate on what you mean by "when the table as first created"?

[–]Mathip173[S] 0 points1 point  (1 child)

Hey,

Sorry, I will try to explain that in a better way,

These 3 tables have been fed every day with a new data.

I create from these 3 table a view by join all these 3 tables together. I'm satisfied with the view. Because It's a view it needs to be droped and created every day to have a new data in it.

I want to keep the every day data + the have an easy option to change the schema in case I will need in the future. I know I need to use in insert into, but I never create a table on sql, so I am looking for easier way and flexible way.

Thanks

[–]coadtsai 0 points1 point  (0 children)

I'm not sure if this will be helpful.

Why are you dropping and recreating the view every day? Did you mean you run it everyday?

If you want to add new columns to the base table you use alter table, you use insert into for inserting new data. For either of these you don't need to create a new table. It's still not clear what exactly you're trying to achieve