1. 首页 > 其他

SQL 语言写? sql语句中的关键字

SQL 语言写?sql语句中的关键字

用SQL语言写出语句

1 INSERT INTO R(NO, NAME, SEX, AGE, CLASS) VALUES(25,'李明‘,'男' ,21,'95031')

2) INSERT INTO R(NO, NAME, AGE, CLASS) VALUES(30,'郑和',30, '95031')

3) update R set name = '王华' WHERE NO = 10

4) UPDATE SET CLASS = '95091' WHERE CLASS = '95101'

5) DELETE FROM R WHERE NO = 20

6) DELETE FROM R WHERE NAME LIKE '王%'

用SQL语言编写程序

这太简单了吧?

SELECT * FROM 表 WHERE 课程='高数' Order By 职称

怎么用SQL语言写???求助!!!

create table score

(

 姓名 varchar(20),

    数学 float,

 英语 float,

 语文 float

)

insert into score values('张三',50,80 ,70)

insert into score values('李四',80,68,82)

insert into score values('黄六',85,78 ,90)

----------------------------

select 姓名,

(case when 数学>英语 and 数学>语文 then 数学 when 英语>语文 then 英语 else 语文 end) 最大分数,

(case when 数学<英语 and 数学<语文 then 数学 when 英语<语文 then 英语 else 语文 end) 最小分数,

round((数学+英语+语文)/3,2) 平均分数

from score

SQL的代码编写

1.create database student_score

2.

create table courseInfo(

courseNo char(6) primary key,

courseName varchar(20) not null

)

3.

create table stuInfo(

StuNo char(6) primary key,

StuName varchar(20) not null,

Sex char(2),

Nation varchar(4) default('汉') not null,

ID varchar(18) unique

)

4.

create table scoreInfo(

ID int identity(1,1) not null,

StuNo char(6),

courseNo char(6),

score float,

constraint fk_id foreign key (stuNO) references stuInfo(stuNo),

constraint fk_Courseno foreign key (courseNo) references courseInfo(courseNo),

constraint check_score check (score>=0 and score<=100)

)

5.

insert into courseInfo values('100101','西班牙语')

insert into courseInfo values('100102','大学英语')

update courseInfo set courseName='专业英语' where courseNo='100102'

delete from courseInfo where courseNo='100101'

6.

create view viewScoreInfo

as

select stuInfo.stuNO as stuNO,stuInfo.stuName as stuName,courseInfo.courseNo as courseNo,courseInfo.courseName as courseName,scoreInfo.score as score from stuInfo

join scoreInfo on scoreInfo.stuNO=stuInfo.stuNo join courseInfo on courseInfo.courseNO=scoreInfo.courseNo

7.select stuName,sex from stuInfo where stuName like '刘%' and sex='女'

8.select stuNo,stuName from viewScoreInfo where score<60

9.

create procedure select_specialScore

@courseName varchar(20)

as

select max(score),min(score),avg(score) from scoreInfo join courseInfo on scoreInfo.courseNo=courseInfo.courseNo where courseName=@courseName

exec select_specialScore '专业英语'//执行存储过程语句