Jump to content

change column names of a table


BrainPill
 Share

Recommended Posts

My question is, if it is possible, to change the name of the column with MYSQL. (not with php)

This is my example:

mysql> select * from horses;
+------------+---------------+-----------------------+---------------------+---------------------+-----------------------------+
| num        | name          | location              | created_day         | changed_day         | key_value                    |
+------------+---------------+-----------------------+---------------------+---------------------+-----------------------------+
|          1 | Horse Riding  | http://www.camping.fr | 2017-03-30 13:40:16 | 2017-10-19 18:14:57 | Horse, Riding, Woods        |
|          2 | Horseriding77 | http://www.wine.com   | 2017-10-27 10:16:59 | 2017-10-27 10:16:59 | Outdoor, Vacances, Test |
|          3 | Horsetours45  | http://www.fake.com   | 2017-10-23 16:18:17 | 2017-10-23 16:18:17 | Outdoor, Vacances, Test |
|          4 | Horsetours57  | http://www.bing.com   | 2017-10-23 17:24:32 | 2017-10-23 17:24:32 | Outdoor, Vacances, Test |
|          5 | Horseriding48 | http://www.test.com   | 2017-10-25 09:05:18 | 2017-10-25 09:05:18 | Outdoor, Vacances, Test |
|          6 | Horseriding67 | http://www.google.uk  | 2017-10-27 10:11:18 | 2017-10-27 10:11:18 | Outdoor, Vacances, Test |
|          7 | Horseriding52 | http://www.google.es  | 2017-10-26 17:00:05 | 2017-10-26 17:00:05 | Outdoor, Vacances, Test |
|          8 | Horseriding57 | http://www.google.fr  | 2017-10-27 12:13:38 | 2017-10-27 12:13:38 | Outdoor, Vacances, Test |
+------------+---------------+-----------------------+---------------------+---------------------+-----------------------------+
8 rows in set (0.03 sec)

mysql>

the idea is that for example location as a column name is changed by mysql into other names.  

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...