user331859
user331859

Reputation: 51

Creating and dropping VIEWS in mysql

When I query a VIEW and display the results then delete the VIEW, will the result still show on master-detail page?

The application I'm developing involves users searching for information in the database. Each search a user makes creates a VIEW that will then be queried and the results of the query will be displayed. I want to delete the VIEW immediately afterwards so as not to have too many views created. The question now is that when I drop the VIEW from the database in mysql, will the query still show the data on my master detail page?

Upvotes: 0

Views: 504

Answers (5)

Álvaro González
Álvaro González

Reputation: 146460

HTTP is a stateless protocol. Once the browser has received the HTML document you can even blow out the server with dynamite and the user won't even notice.

Upvotes: 0

Hammerite
Hammerite

Reputation: 22340

I don't know what you mean by "master detail page". When you execute an SQL statement, you receive one or more result sets back. What you do after that point will not have any effect on the result set that has already been computed. So if you

- define a view
- query the view
- drop the view

the result set you got back from querying the view is not going to be affected by dropping it afterwards.

As others have said, it doesn't make sense to define a view if you're only going to use it once, and then drop it. You may as well just run the underlying query.

Upvotes: 0

Stuart
Stuart

Reputation: 1

I'd also not recommend that the MySQL user be allowed to run any DDL statements, if possible, it's safer that way.

Upvotes: 0

Devart
Devart

Reputation: 121932

If you read all dataset, and then removed the view, next time query won't work.

Why not to use just queries, instead of views?

Upvotes: 2

Scotty Waggoner
Scotty Waggoner

Reputation: 3380

Would just using a SELECT statement be better than creating a VIEW for each query and then deleting it?

Upvotes: 1

Related Questions