编写以下语句
1.创建dept表
2.创建emp表
3.将列Last_name的长度增加到50
4.根据表emp创建employees2
5.删除表employees2
6.在表dept和emp中添加新列test_column,并检查所作的操作
7.在表dept和emp中将列test_column删除
8.直接删除表emp中的列 dept_id
答:
1.
create table dept(id int not null,name varchar(25) not null,location varchar(25))
2.
create table emp(id int,First_name varchar(25),Last_name varchar(25),dept_id int)
3.
drop table emp;create table emp(id int,First_name varchar(25),Last_name varchar(25),dept_id int);alter table emp modify column last_name varchar(50);
4.
drop table emp;create table emp(id int,First_name varchar(25),Last_name varchar(25),dept_id int);create table employees2select * from emp
5.
drop table employees2;
6.
alter table dept add test_column varchar(255);alter table emp add test_column varchar(255);
7.
alter table dept drop test_column;alter table emp drop test_column;
8.
alter table emp drop column dept_id;
如果觉得《【Sql语句】创建表 修改 删除表 增添列 删除列》对你有帮助,请点赞、收藏,并留下你的观点哦!