aspose file tools*
The moose likes JDBC and the fly likes Index and view in a database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Index and view in a database." Watch "Index and view in a database." New topic
Author

Index and view in a database.

Rd Dari
Ranch Hand

Joined: Feb 22, 2010
Posts: 211

Hi all,

Please clear that , there is a base table named A consists 10 records , then how many records in a view. And if I delete a record from table then in the view how many records will be.


Thanks!!
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

It depends on the definition of the view, of course.

View in a relational database is just a stored SQL query that is executed against the table(s) whenever the view is used.

Index is yet another thing. Generally, indexes should not affect results of SQL databases; they are there to speed up some SQL queries or to enforce database constraints.
Rd Dari
Ranch Hand

Joined: Feb 22, 2010
Posts: 211

OK
one more question is that if I drop table A then index and view will be drop or not?
Thanks for your reply!
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

It might differ depending on the database, but generally indexes are dropped when the table is dropped. Views are usually kept in an invalid state, they are unusable until fixed.
Vinod Tiwari
Ranch Hand

Joined: Feb 06, 2008
Posts: 459
    
    1
Like Martin rightly pointed its database specific like in Oracle if you drop table view and indexes both would be dropped but in DB2 if you drop table then views on the table are marked inoperative and indexes are dropped.


Vinod Tiwari | Twitter
Rd Dari
Ranch Hand

Joined: Feb 22, 2010
Posts: 211

Thanks all of you for a good and soon reply !

I really appreciate this Forum site.
 
jQuery in Action, 2nd edition
 
subject: Index and view in a database.