View Full Version : Modifying/Deleting mySQL tables using PHP
pizzaguy234
March 4th, 2005, 02:58 PM
Hey guys, just wondering if you hav any idea how to delete, or modify (add a column) to a mySQL table, using a PHP script, so far all i can do is add data, and create the entire table using PHP.
Thanks in advance guys, laters. Andy.
SmoothDime
March 4th, 2005, 03:22 PM
column or row?
if you want to delete a column use ALTER TABLE.
if you want to delete a row use DELETE.
peace
binime
March 5th, 2005, 04:30 AM
<?php
mysql_query("DROP DATABASE `databasename`");
//this will drop a database
mysql_query("DROP TABLE `tablename`");
//will permanently remove a table
mysql_query("TRUNCATE TABLE `tablename`");
//this will remove all rows inside the table
mysql_query("ALTER TABLE `tablename` CHANGE `fieldname` `newfieldname` type DEFAULT 'default value' NOT NULL");
//alter a tables field attributes
mysql_query("ALTER TABLE `tablename` RENAME `newtablename` ;");
//this will change a tables name
mysql_query("ALTER TABLE `tablename` DROP `fieldname` ;");
//this remove a field from inside the table
?>
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.