Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql alter comment column only

Tags:

mysql

alter

I'm wondering if it's possible to change only comment on a column in mysql without change the column definition data like name, type and key.

Example:

ALTER TABLE `user` CHANGE `id` `id` INT(11) COMMENT 'id of user' 

Can i change only the comment is this example ?

Thanks in adavance.

like image 801
chaillouvincent Avatar asked Apr 01 '15 08:04

chaillouvincent


People also ask

How do I comment a column in MySQL?

The comments can be added to the MySQL columns while creating a table by adding the COMMENT keyword after the column definition, as shown above for column emp_name. The table is created successfully with comments. Confirm the same in column information using MySQL workbench.

How do I edit a column in MySQL?

The syntax to modify a column in a table in MySQL (using the ALTER TABLE statement) is: ALTER TABLE table_name MODIFY column_name column_definition [ FIRST | AFTER column_name ]; table_name. The name of the table to modify.

How do you make a column NOT NULL in MySQL?

To enforce NOT NULL for a column in MySQL, you use the ALTER TABLE .... MODIFY command and restate the column definition, adding the NOT NULL attribute.

How do I add comments to a column in phpmyadmin?

To edit column comments select a column by checking the box to the left of its name and click on the Change button. This action will open a column editor where you can add or edit a comment in the Comments field.

How can we use MySQL ALTER TABLE command for adding comments?

How can we use MySQL ALTER TABLE command for adding comments on columns? We can use ‘COMMENT’ keyword with ALTER TABLE command while modifying the column to add comments on columns. For example if we want to add comment in column ‘id’ of table ‘testing’ then following query will do it −

What is the MySQL alter column query?

The MySQL ALTER COLUMN query is a MySQL statement that is responsible to change the structure of a table, either for adding a table column, altering the column, renaming the column, removing the column or renaming the table itself.

Can the word column be omitted in a MySQL ALTER TABLE statement?

The word COLUMN is optional and can be omitted. Multiple ADD, ALTER , DROP, and CHANGE clauses are permitted in a single ALTER TABLE statement, separated by commas. This is a MySQL extension to standard SQL, which permits only one of each clause per ALTER TABLE statement. For example, to drop multiple columns in a single statement, do this:

How to add a column after the last column in MySQL?

There are two options you can either add the table column after the last column existing in the table using AFTER ColumnNameKeyword or, as first column using FIRST ColumnNamekeyword. But if these options are not provided in the ALTER ADD COLUMN query then, the new table column will be affixed at the end of the list of columns in the table.


1 Answers

According to the MySQL specification, you must repeat the entire column definition if you want to redefine the comment:

ALTER TABLE user MODIFY id INT(11) COMMENT 'id of user';
like image 131
Tim Biegeleisen Avatar answered Oct 19 '22 07:10

Tim Biegeleisen