Click to See Complete Forum and Search --> : changing a table name


Markbad311
01-18-2006, 08:39 AM
I have MySql 4.4.1

I am looking for the query string to change the name of a table. Not its fields is this possible?

Brooksie155
01-18-2006, 09:10 AM
ALTER TABLE `current_name` RENAME `new_name`

Markbad311
01-18-2006, 02:40 PM
awesome Thank you. They didn't have the RENAME syntax listed in my book. What about closing DataBase Connections? When should I do this and what is the syntax? I am using PHP

Brooksie155
02-10-2006, 08:53 AM
in php you just call:

mysql_close($rs);

Where $rs is the recordset returned from

$rs = mysql_query("SELECT .... ");

The safe way of doing this is to have a header and a footer file which you can include in every file that uses the DB, where the header opens the connection and the footer closes it. Although if you are not using persistent connections I think MySQL tends to close them for you - otherwise if they are persistent they will wait for another request.

More important is to use is:

mysql_free_result($rs);

especially if you run a query which returns a lot of rows, as this will clear any record data stored in memory, thus freeing it for the next user.