List:General Discussion« Previous MessageNext Message »
From:Steve Edberg Date:July 2 2002 7:48pm
Subject:Re: changing coulmn
View as plain text  
I wasn't entirely sure what you wanted - do you want to change the 
table's column names? If so, then do what the message below suggests. 
And yes, you can do it all in one query:

    alter table mytest
    change my_1 my_file_1 varchar(5),
    change my_2 my_file_2 varchar(5),
    ...and so on

See

    http://www.mysql.com/doc/A/L/ALTER_TABLE.html

for more info.

If my_1, etc are VALUES in a column, and you want to modify them, you 
can do this:

    update your_table_name
    set your_column_name =
       concat('my_file_', substring(your_column_name, 4))

See

    http://www.mysql.com/doc/S/t/String_functions.html

for more info.

	-steve


At 2:32 PM -0400 7/2/02, Anil Garg wrote:
>thanx for ur mail, m sorry in dint mention that infact its a big table...
>Is there a way i can do it in all the columns using only one query ??
>thanx
>anil
>----- Original Message -----
>From: "nellA hciR" <g3pb@stripped>
>To: "Anil Garg" <anilg@stripped>
>Cc: <mysql@stripped>
>Sent: Tuesday, July 02, 2002 2:14 PM
>Subject: Re: changing coulmn
>
>
>>  mysql> create table mytest (
>>       -> my_1 varchar(5)
>>       -> );
>>  Query OK, 0 rows affected (0.32 sec)
>>
>  > mysql> alter table mytest change my_1 my_file_1 varchar(5);
>>  Query OK, 0 rows affected (0.23 sec)
>>  Records: 0  Duplicates: 0  Warnings: 0
>>
>>  mysql> show columns from mytest;
>>  +-----------+------------+------+-----+---------+-------+
>>  | Field     | Type       | Null | Key | Default | Extra |
>>  +-----------+------------+------+-----+---------+-------+
>>  | my_file_1 | varchar(5) | YES  |     | NULL    |       |
>>  +-----------+------------+------+-----+---------+-------+
>>
>>  On Tuesday, July 2, 2002, at 09:36 , Anil Garg wrote:
>>
>>  > in my table a column has enties
>>  > my_1
>>  > my_4
>>  > my_5
>>  >
>>  > i wnat to change it to
>>  >  my_file_1
>>  >  my_file_4
>>  >  my_file_5
>  >
>


-- 
+------------------------------------------------------------------------+
| Steve Edberg                                      sbedberg@stripped |
| University of California, Davis                          (530)754-9127 |
| Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| The end to politics as usual:                                          |
|                 The Monster Raving Loony Party (http://www.omrlp.com/) |
+------------------------------------------------------------------------+
Thread
changing coulmnAnil Garg2 Jul
  • Re: changing coulmnnellA hciR2 Jul
    • Re: changing coulmnAnil Garg2 Jul
      • Re: changing coulmnSteve Edberg2 Jul