Reputation: 41260
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.
Upvotes: 23
Views: 50927
Reputation: 65
FLUSH TABLES
is done for all databases, except if you specify tables one by one.
the syntax is:
FLUSH TABLES tbl_name [, tbl_name] ...
with READ LOCK
:
FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK
and to contain all tables within a database, you can get query SHOW TABLES
to display all tables from the selected database. so with some edits, the query will be something like this:
FLUSH TABLES db_name.table_1,
db_name.table_2,
db_name.table_3,
...
Upvotes: 0
Reputation:
when you do just a mysql_connect and then "show tables" for example -> mysql_error(): No Database selected
with "flush tables" there is no mysql_error, so i think the answer is every database
Upvotes: 7
Reputation: 562731
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.
Upvotes: 11