π是投影,该运算从表中选出指定的属性组成一个新表,记为:πA(R)其中A是属性名(即列名)表,R是表名
σ是选择,该运算按给定的条件,从表中选出满足条件的行形成一个新表,作为一个新表如:σF(R)其中F为条件表达式,R为表名
1 π姓名,家庭地址σ 职务='科长'(职工)
2 π姓名,家庭地址σ 部门部门名称='办公室'∧职工职务='科长'(部门部门编号∞职工所属部门编号)
3 π姓名,家庭地址σ部门名称='财务科'∧职务= '科长'(部门部门编号∞职工所属部门编号)
4 del from 职工 where 职工号='3016'
5 update 保健 set 健康状况='一般' where 职工号='3016'
6 create view 视图名 as selcet from 保健 where 健康状况='差'
1、select 图书编号,书名,定价 from 图书 where 出版社标号='CS';
2、select 图书书名,图书定价,出版社出版社名称 from 图书,出版社 where 图书分类='教材' and 图书出版社编号=出版社出版社编号;
3、select 出版社编号,count(图书编号),avg(定价) from 图书 group by 出版社编号;
4、select 图书图书编号,图书书名 from 图书,出版社 where 图书分类='教材' and 图书出版社编号=出版社出版社编号 and 出版社出版社编号=‘高等教育出版社’ and 图书定价>30;
1
select ssno,ssname from s,c,sc where ssno=scsno and ccno=sccno and ccname='MS'
2
select sno from sc where cno='C1' and sno in (select sno from sc where cno='C3')
3
select ssno,scgrade from s,c,sc where ssno=scsno and ccno=sccno and ccname in('数据库',' *** 作系统')
4
select sno,sname,age from s where 性别='女' and age between 18 and 20
5
select ssno,ssname,scgrade from s,c,sc where ssno=scsno and ccno=sccno and cteacher='刘平'
6
select distinct ssname from s,sc where ssno=scsno and cno in(select cno from sc having count(distinct cno)=(select count() from c))
7
select distinct sname from s where sno in(select sno from sc where cno in(select cno from sc where sno='1042') group by sno having count()=(select count() from sc where sno='1042'))
8
select sname,age,所在系 from s where sname like '樊%'
9
select sname,age,所在系 from s where sno in(select sno from sc group by sno having count()>3)
其中4,8,9,你给的字段里分辨不出来哪些字段是性别和所在系,根据实际情况自己替换
1
CREATE DATABASE [Nor] ON (NAME = N'Nor', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\normdf' , SIZE = 4, FILEGROWTH = 10%) LOG ON (NAME = N'Nor_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\norldf' , SIZE = 1, FILEGROWTH = 10%)
COLLATE Chinese_PRC_CI_AS
GO
exec sp_dboption N'Nor', N'autoclose', N'false'
GO
exec sp_dboption N'Nor', N'bulkcopy', N'true'
GO
exec sp_dboption N'Nor', N'trunc log', N'true'
GO
exec sp_dboption N'Nor', N'torn page detection', N'true'
GO
exec sp_dboption N'Nor', N'read only', N'false'
GO
exec sp_dboption N'Nor', N'dbo use', N'false'
GO
exec sp_dboption N'Nor', N'single', N'false'
GO
exec sp_dboption N'Nor', N'autoshrink', N'false'
GO
exec sp_dboption N'Nor', N'ANSI null default', N'false'
GO
exec sp_dboption N'Nor', N'recursive triggers', N'false'
GO
exec sp_dboption N'Nor', N'ANSI nulls', N'false'
GO
exec sp_dboption N'Nor', N'concat null yields null', N'false'
GO
exec sp_dboption N'Nor', N'cursor close on commit', N'false'
GO
exec sp_dboption N'Nor', N'default to local cursor', N'false'
GO
exec sp_dboption N'Nor', N'quoted identifier', N'false'
GO
exec sp_dboption N'Nor', N'ANSI warnings', N'false'
GO
exec sp_dboption N'Nor', N'auto create statistics', N'true'
GO
exec sp_dboption N'Nor', N'auto update statistics', N'true'
GO
if( (@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 724) )
exec sp_dboption N'Nor', N'db chaining', N'false'
GO
2
select into nordboorders from northwinddboorders where 1=0
3
insert into nordboorders ( [CustomerID], [EmployeeID], [OrderDate], [RequiredDate], [ShippedDate], [ShipVia], [Freight], [ShipName], [ShipAddress], [ShipCity], [ShipRegion], [ShipPostalCode], [ShipCountry]) (select [CustomerID], [EmployeeID], [OrderDate], [RequiredDate], [ShippedDate], [ShipVia], [Freight], [ShipName], [ShipAddress], [ShipCity], [ShipRegion], [ShipPostalCode], [ShipCountry] from northwinddboorders)
4
UPDATE [Northwind][dbo][orders]
SET freight=freight15
5
insert into employees (lastname,firstname)
values ('bb','aa')
6
update nororders
set norordersorderdate=(select northwindordersorderdate from northwindorders
where northwindorderscustomerid=nororderscustomerid
and northwindordersemployeeid=norordersemployeeid
and northwindordersshipvia=norordersshipvia
and northwindordersfreight=norordersfreight)
7
DELETE FROM [Nor][dbo][orders]
WHERE employeeid in (select employeeid from northwindemployees)
自定义的列名,因为你有用到函数,sum和avg是函数方法,那么用它们查询出来的结果,所显示的列名
都是
“无列名”,那么加了
as
什么什么
接在函数后面,那么显示查询结果时,这个名称就是它的列名,方便列作用的理解。
其实你只要将这条语句
分加
as
和不加as
到数据库里执行一遍就能看出比对结果来了
1 select '类别为:'+tushuleibie 图书分类 from T_Book
2 select shuming 书名,zuozhe 作者,jiage07 价格 from T_Book where chubanshe ='机械工业出版社'
3 select shuming 书名,zuozhe 作者,jiage 价格, chubanshe 出版社 from T_Book where jiage between 30 and 60
4 select top 3 shuming 书名,zuozhe 作者,chubanshe 出版社, jiage 价格 from T_Book order by jiage desc
6select chubanshe 出版社,AVG(jaige) 平均价,MAX(jiage) 最高价 ,MIN(jaige) 最低价 from T_Book group by chubanshe order by SUM(jiage) desc
10select top 1 chubanshe 出版社, count() 出版图书个数 from T_Book group by chubanshe order by COUNT() desc
book表的做好了 reader的自己做吧 字段名我用拼音做代替的 你自己替换成你表中的字段
以上就是关于一道数据库题目,谁能帮我解答下,急!!!全部的内容,包括:一道数据库题目,谁能帮我解答下,急!!!、数据库检索SQL语句题目求 解答、关于数据库的题目等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)