View Single Post

   
  #5 (permalink)  
Old 02-28-2008, 11:29 AM
Gordon Burditt
 
Posts: n/a
Default Re: Closing a database

>Thanks for the answer. I perceived the "use" command as if it were
>actually opening the file at the time and, thus, quitting MySQL or


You can view it that way. At this point it wil check the existence
of the database and your permissions to access it.

>shutting down the computer without issuing a close command could corrupt
>the file.


Quitting MySQL (the 'quit' command to the command interpreter, or
mysql_close() from the C or PHP API) is a correct way to close the
database. Another way is to switch to another database. An unclean
disconnect (e.g. your program dumping core) will cause MySQL to
roll back uncommitted transactions. The main opportunity for
corrupted files is to get halfway through making a set of changes,
not using transactions, then crash.

Opening a file for read, then crashing your program or the system
is unlikely to corrupt the file. Even opening the file for write
(without truncating it), then crashing is not likely to corrupt the
file. Half-completed changes are the main opportunity for corrupted
files.

>However, from what it seems (and please correct me if my
>understanding is in error), the "use" command is more like "Assign" in
>Pascal: it assigns a filename with which file commands will be used but
>does nothing with the file itself. Is this correct?

Reply With Quote