创建表
create table corporation(
corp_id int,
name varchar(30),
CONSTRAINT pk_corporation PRIMARY KEY (corp_id)
);
去掉重复的行
select distinct corp_id from corporation
插入
insert into corporation(corp_id, name)
values(27,'Apc');
修改
update corporation set name = 'abc' where corp_id = 27
删除
delete from corporation where corp_id = 27
删除表
drop table corporation
创建视图
create view corp_view as
select * from corporation;
查看视图
select corp_id from corp_view;
根据后3位排序查询
select * from corporation order by right(corp_id, 3);‘
按年查询
select * from employee where year(startdate) = '2012'
按第一个字母查询
select * from employee where left(name, 1) = 'T'