Does the MySQL command :
FLUSH TABLES;
flush every table in the current database, or every table on the server ?
I'm using MySQL 5.0 - the documentation is unclear, although it does mention that :
FLUSH TABLES WITH READ LOCK;
will do so for ALL databases.
Thanks.
The idea of FLUSH TABLES is to force all tables to be closed. This is mainly to ensure that if someone adds a new table outside of MySQL (for example, by copying files into a database directory with cp ), all threads will start using the new table.
when we grant some privileges for a user, running the command flush privileges will reloads the grant tables in the mysql database enabling the changes to take effect without reloading or restarting mysql service. mysql> FLUSH TABLES; The command closes all tables which are currently open or in use.
Writing a buffer to disk is called buffer flushing . When a user thread modifies data in a buffer, it marks the buffer as dirty . When the database server flushes the buffer to disk, it subsequently marks the buffer as not dirty and allows the data in the buffer to be overwritten.
FLUSH TABLES WITH READ LOCK is useful if you want to take a backup of some tables. When FLUSH TABLES WITH READ LOCK returns, all write access to tables are blocked and all tables are marked as 'properly closed' on disk. The tables can still be used for read operations.
It's all databases.
I tried to look this up but I couldn't find an authoritative answer either.
FLUSH TABLES
, but it doesn't say specifically.mysql_server/sql/sql_base.cc
but couldn't find the answer quickly.I assume the answer is one of those things that the developers feel is so obvious that they never need to say it.
According to the internals doc, the MySQL table cache holds a list of of most recently used tables. There is no mention of database-specific table caches, there seems to be only one table cache in the MySQL Server.
FLUSH TABLES
is described as forcing all open tables (those in the table cache) to be closed. There is no mention of this being limited to one database, but you can specify individual tables in the arguments to FLUSH TABLES
. So likewise, I assume this applies to the whole table cache by default, and therefore to all databases with open files on the MySQL Server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With