28

I have existing table which is called person, I want to add via MySQL Workbench new column into it, for example column age. How can I manage this operation using this program, where and what I need to write?

I found query like this, should it works?

ALTER TABLE person ADD age INT(3);
4
  • 1
    Generally it's a bad idea to hold age in a table because it will be wrong as soon as it's added. Commented Oct 13, 2017 at 7:18
  • 1
    I just add this for example, of course I don't want to add something like this to table. How I said, it just for example. Could you help me with this? Commented Oct 13, 2017 at 7:19
  • Why don't you just try it and see mysql will complain if it doesn't like it also dev.mysql.com/doc/refman/5.7/en/alter-table.html Commented Oct 13, 2017 at 7:25
  • I want to learn how to use MySQL Workbench, because my company required it, so if you could tell me how to do it in this program (where I should wrote this) you would save my day. Commented Oct 13, 2017 at 7:28

2 Answers 2

77

I don't know if Stackoverflow is proper place to such question, but...

Click on the table you want to change (using right mouse button) and choose "Alter table" (schemas and tables lists are on the left).

enter image description here

In the opened tab you can add or change columns (GUI is very simple and intuitive).

enter image description here

Don't forget to save changes by clicking "Apply".

Sign up to request clarification or add additional context in comments.

2 Comments

I wouldnt say intuitive as I had to search to find the answer to this, it's a hidden column that you double click to create. Spent ages looking for a 'new column' button.
Where is the "Apply" button ?
0

I don't know if you have your answer, I know this thread is very old but in case someone else is looking, I just learned how to do this myself:

The syntax is:

ALTER TABLE person ADD COLUMN age INT;

Always list the datatype after the new column name. I hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.