instagram

Wednesday, February 9, 2011

SQL Alter Column Name

user_table

+--------+----------+-----------+
| user_id| username | fullName  |
+--------+----------+-----------+
| 1      | shakira  | shakirah  |
| 2      | calvin   |calvin ang |
| 3      | sunny    | sunny loi |
| 4      | emily    | emily kong|
| 5      | shah     | mohd shah |
+--------+----------+-----------+

Syntax
The ALTER  table statement in SQL is used to modify the table 'user_table' and change keyword change the name of field to new  name of field. The syntax used for Alter Table is given below:

Alter table table_name change old_column_name  new_column_name type size

Query
The Alter Table alter the table 'user_table'. The change keyword change the column name of  user_id to id in table 'user_table'.

Alter table user_table change user_id id varchar(10)

user_table

+--------+----------+-----------+
| id     | username | fullName  |
+--------+----------+-----------+
| 1      | shakira  | shakirah  |
| 2      | calvin   |calvin ang |
| 3      | sunny    | sunny loi |
| 4      | emily    | emily kong|
| 5      | shah     | mohd shah |
+--------+----------+-----------+

** sumber : http://www.roseindia.net/sql/sql-alter-column-name.shtml

No comments:

LinkWithin

Related Posts Plugin for WordPress, Blogger...