Search Marketing

   
   

Renaming Table Names Using Change Option in the Alter Statement

Fri May 02, 2008 9:56 pm
<<     >>
Comments: 0 Views: 1281

If we have the following database table structure.

mysql> select * from Name;
+----+--------+---------------------+
| ID | Name | Date |
+----+--------+---------------------+
| 1 | Joe | 2001-02-12 00:00:00 |
| 2 | Jack | 2003-03-15 00:00:00 |
| 3 | John | 1980-05-15 00:00:00 |
| 4 | James | 1994-09-21 00:00:00 |
| 5 | George | 1996-12-11 00:00:00 |
+----+--------+---------------------+

Lets assume we wanted to change the name of the table to “Tracking”.

mysql> alter table Name rename as Tracking;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from Tracking;
+----+--------+---------------------+
| ID | Name | Date |
+----+--------+---------------------+
| 1 | Joe | 2001-02-12 00:00:00 |
| 2 | Jack | 2003-03-15 00:00:00 |
| 3 | John | 1980-05-15 00:00:00 |
| 4 | James | 1994-09-21 00:00:00 |
| 5 | George | 1996-12-11 00:00:00 |
+----+--------+---------------------+

Remember to backup your database, or copy the /var/lib/mysql source files to a safe location before attempting to utilize commands that may change the structure of your database.



Comments
Name:
*
URL: http: (ex. cnn.com)
Comment:
*
Number:
Math (18 + 2)
* required
SubCategories
Books

© 2017 Christonium LLC

Christonium.com
|
Terms of Use
|
Privacy
ccc