Jump to content

How To Change An Item On Database


satimis
 Share

Recommended Posts

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

Edited by satimis
Link to comment
Share on other sites

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) ;

Edited by jlhaslip
Link to comment
Share on other sites

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 commands
mysql> 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

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

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

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...