question

vivekyadav0212 avatar image
vivekyadav0212 asked

What is the difference between 'INSERT INTO TABLE' and 'INSERT INTO VIEW'

Hello Wanted to know your thoughts on this- What is the difference between 'INSERT INTO TABLE' and 'INSERT INTO VIEW' AND here view is not Indexed View and also not getting the data from 2 or more different tables. It is just SELECT Col1, Col2.... from TABLE What could be the possibel advantage of using INSERT INTO VIEW instead of inserting directly into table.
sqlview
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Grant Fritchey avatar image
Grant Fritchey answered
Effectively, no real difference. You're just inserting into a table no matter which way you go since a view is just a query, not the underlying data. The only thing you can do with a view that you can't do with a table is mask the columns on display if you wanted to hide calculated or nullable columns from the user. You can't hide columns that are not nullable unless you have a default value for them. But the only reason I could see to use something like this is if you had an app that exposed tables for direct insert, which is a horrible idea. You'd want to always have some type of application in front helping to ensure the cleanliness of the data.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks Grant. It is very well explained and I also think it because user doesn't want to expose tables.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.