我用的是Mysql图形界面化工具是DataGrip,首先我直接新建了一个数据库,然后再用sql语句创建customers表和其中的字段,具体操作如下:
1.根据要求,c_num不能为空且是主键并且自增
c_birth也不能为空
2.将c_contact字段插入c_birth字段后面:
alter table customers_info add c_contact varchar(50) after c_birth;
3.将c_name字段数据类型改为VARCHAR(70):
alter table customers modify c_name varchar(70);
4.将c_contact字段改名为c_phone:
alter table customers change c_contact c_phone varchar(50);
5.增加c_gender字段,数据类型为CHAR(1):
alter table customers add c_gender char(1);
6.将表名修改为customers_info:
alter table customers rename to customers_info;
7.删除字段c_city:
alter table customers_info drop c_city;
8.修改数据表的存储引擎:
alter table customers_info engine = MyISAM;
9.在Market中创建数据表orders:
CREATE TABLE `orders` (
`o_date` date DEFAULT NULL,
`o_id` int(11) DEFAULT NULL,
`o_num` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`o_num`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1