sql 基本操作


create table stu(
sno varchar(20) primary key,
sname varchar(20),
sex varchar(2)
);
create table score(
studentid varchar(20) primary key,
subject varchar(20),
score int,
foreign key (studentid) REFERENCES stu(sno)
);

insert into stu(sno,sname,sex) values('10001','杨利伟','男');
insert into score(studentid,subject,score) values ('10001','英语',80);

delete score where studentid = '10001';
delete stu where sno = '10001';

update stu set sname = '航天员' where sno = '10001';
update stu set sex = '男' where sno = '10001';

select * from stu;
select * from score;

select stu.sno,stu.sname,score.subject,score.score
from stu,score
where stu.sno = score.studentid;

猜你喜欢

转载自blog.csdn.net/qq_32674347/article/details/81195633