We help IT Professionals succeed at work.
Get Started

how do you alter the table once it is created with loosing the data? thanks

goodk asked
Last Modified: 2021-04-21
ok, if I create the database table as following, and a day later I want to add a new field " `ae_city` varchar(50) NOT NULL" and modify the ae_name to 80, how would I do it.  I do not want to loose any data

CREATE TABLE `ajax_example` (
  `ae_name` varchar(50) NOT NULL,
  `ae_age` int(11) NOT NULL,
  `ae_sex` varchar(1) NOT NULL,
  `ae_wpm` int(11) NOT NULL,
  PRIMARY KEY  (`ae_name`)

-- Dumping data for table `ajax_example`

INSERT INTO `ajax_example` VALUES ('Jerry Lewis', 120, 'm', 20);
INSERT INTO `ajax_example` VALUES ('Regis Philbin', 75, 'm', 44);
INSERT INTO `ajax_example` VALUES ('Frank Furt', 45, 'm', 87);
INSERT INTO `ajax_example` VALUES ('Jill Hill', 22, 'f', 72);
INSERT INTO `ajax_example` VALUES ('Tracy Sax', 27, 'f', 0);
INSERT INTO `ajax_example` VALUES ('Julie Barker', 35, 'f', 90);
INSERT INTO `ajax_example` VALUES ('Blake Black', 54, 'm', 30);
INSERT INTO `ajax_example` VALUES ('Jack Black', 30, 'm', 20);
INSERT INTO `ajax_example` VALUES ('Martina White', 14, 'f', 114);
INSERT INTO `ajax_example` VALUES ('Martin White', 41, 'm', 32);
INSERT INTO `ajax_example` VALUES ('Jason Biggs', 23, 'm', 4);
INSERT INTO `ajax_example` VALUES ('Colin Smith', 21, 'm', 50);
Watch Question
Top Expert 2011
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE