数据库第四天

2.查看该库下几个表以及查看两张表结构。
3.将表employees的mobile字段修改到officeCode字段后面。
4.将表employees的birth字段改名为employee birth。
5.修改sex字段,数据类型为CHAR(1),非空约束。
6.删除字段note。
7.增加字段名favoriate activity,数据类型为VARCHAR(100)。
8.删除表offices.
9.将表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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值