查看该库下几个表以及查看两张表结构。
将表employees的mobile字段修改到officeCode字段后面。
将表employees的birth字段改名为employee birth。
修改sex字段,数据类型为CHAR(1),非空约束。
删除字段note。
增加字段名favoriate activity,数据类型为VARCHAR(100)。
删除表offices.
将表employees名称修改为employees_info
create database company;
create table offices(
officeCode int(10) primary key not null unique,
city varchar(50) not null,
address varchar(50),
country varchar(50) not null,
postalCode varchar(15) unique
);
create table employees(
employeeNumber int(11) primary key not null unique auto_increment,
lsatName varchar(50) not null,
firstName varchar(50) not null,
mobile varchar(25) unique,
officeCode int(10) not null,
jobTitle varchar(50) not null,
birth datetime not null,
note varchar(255),
sex varchar(5)
);
ALTER table employees add CONSTRAINT fk_emp_com FOREIGN key(officeCode) REFERENCES offices(officeCode);
show TABLES;
desc employees ;
desc offices;
insert into offices(officeCode) select mobile from employees;
SELECT * FROM offices
alter table employees change birth wth int
alter table employees MODIFY sex char(1) not null
alter table employees drop note
alter table employees ADD favoriate_activity VARCHAR(100)
alter table employees drop FOREIGN key fk_emp_com
drop table offices
alter table employees rename employees_info