This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 206

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: 3606
    
  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: 206

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: 3606
    
  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: 206

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.
 
Similar Threads
database data -to-> List view, how
SQLException error: "Invalid Cursor position"
How to display variant number of record each page based on user's request ?
How to display variant number of record each page based on user's request ?
Optimizing an SQL Query