satimis Posted May 15, 2009 Share Posted May 15, 2009 Hi folks,Ran following entry creating a database; mysql> INSERT INTO users (id,name,maildir,clear) VALUES -> ('xyz@aaa.com','xyz','xyz/', encrypt('password') ), -> etc. -> etc. -> etc.;Query OK, 4 rows affected (0.00 sec)Records: 4 Duplicates: 0 Warnings: 0 Now I need changing "clear" to "crypt"Please advise how to make such a change. TIAB.R.satimis Link to comment Share on other sites More sharing options...
jlhaslip Posted May 15, 2009 Share Posted May 15, 2009 Change is used to alter an existing column in a MySQL table. You can use change to rename a column by providing both the old column name, and the new column name. It is written as: alter table [table name] change [old column name] [new column name] varchar (30) ;ALTER users CHANGE clear crypt varchar (30) ; Link to comment Share on other sites More sharing options...
satimis Posted May 16, 2009 Author Share Posted May 16, 2009 Change is used to alter an existing column in a MySQL table. You can use change to rename a column by providing both the old column name, and the new column name. It is written as: alter table [table name] change [old column name] [new column name] varchar (30) ;ALTER users CHANGE clear crypt varchar (30) ;Hi jlhaslip,Thanks for your advice.I'll run following commandsmysql> USE database;mysql> ALTER users CHANGE clear crypt varchar (30); According to 12.1.7. ALTER TABLE Syntaxhttp://dev.mysql.com/doc/refman/5.1/en/alter-table.html CHANGE [COLUMN] old_col_name new_col_name column_definition [FIRST|AFTER col_name] I suppose "varchar (30)" is column_definition ? Where to find it?What is [FIRST|AFTER col_name] ?TIAB.R.satimis Link to comment Share on other sites More sharing options...
Synook Posted May 16, 2009 Share Posted May 16, 2009 The column definition is the data type and everything else, like you specified in the initial CREATE statement.The [FIRST|AFTER col_name] section if for if you want to move the column's position to a different place. Link to comment Share on other sites More sharing options...
satimis Posted May 16, 2009 Author Share Posted May 16, 2009 Hi Synook,Thanks for your advice. The column definition is the data type and everything else, like you specified in the initial CREATE statement.If I don't change the column definition can I leave it without retyping it on the command?The [FIRST|AFTER col_name] section if for if you want to move the column's position to a different place.Could you please help me to understand the command to be entered? For example in my case;INSERT INTO users (id,name,maildir,clear) VALUES If I need to move "name" after "clear", whether typing; -> ALTER users CHANGE name | clear TIAB.R.satimis Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.