首页 > 代码库 > SQL基础2
SQL基础2
create database fuxi --创建一个名为“fuxi”的数据库
go --连接语句
use fuxi --使用名为“fuxi”的数据库
go
create table hua --创建名为“hua”的表
(
--在表内添加列
gonghao int,
mingzi varchar(10),
gongzi int,
bumen varchar(10),
nianling int,
)
go
--插入数据
insert into hua values(1,‘张三‘,2600,‘销售部‘,26)
insert into hua values(2,‘石头‘,3600,‘售后部‘,21)
insert into hua values(3,‘刑宗‘,6000,‘管理部‘,33)
insert into hua values(4,‘雷霆‘,3800,‘维修部‘,26)
go
--查询数据
select *from hua
select gongzi,mingzi from hua
select bumen,gongzi from hua where mingzi=‘雷霆‘
select *from hua where gongzi between 3800 and 6000
--修改数据
update hua set gonghao=1
update hua set mingzi=‘雷霆‘ where gonghao=4
update hua set bumen=‘维修部‘ where gongzi between 2600 and 3600
alter table hua add en int
--删除数据
alter table hua drop column en
delete from hua where mingzi=‘雷霆‘
delete from hua
drop table hua
drop database fuxi
SQL基础2