oracle中exist与in的区别

oracle中exist与in的区别
oracle中exist与in的区别

在Oracle SQL中取数据时有时要用到in 和exists 那么他们有什么区别呢?

1 性能上的比较

比如Select * from T1 where x in ( select y from T2 )

执行的过程相当于:

select *

from t1, ( select distinct y from t2 ) t2

where t1.x = t2.y;

相对的

select * from t1 where exists ( select null from t2 where y = x )

执行的过程相当于:

for x in ( select * from t1 )

loop

if ( exists ( select null from t2 where y = x.x )

then

OUTPUT THE RECORD

end if

end loop

表 T1 不可避免的要被完全扫描一遍

分别适用在什么情况?

以子查询 ( select y from T2 )为考虑方向

如果子查询的结果集很大需要消耗很多时间,但是T1比较小执行( select null from t2 where y = x.x )非常快,那么exists就比较适合用在这里

相对应得子查询的结果集比较小的时候就应该使用in.

2 含义上的比较

在标准的scott/tiger用户下

执行

SQL> select count(*) from emp where empno not in ( select mgr from emp );

COUNT(*)

----------

SQL> select count(*) from emp T1

2 where not exists ( select null from emp T2 where t2.mgr = t1.empno ); -- 这里子查询中取出null并没有什么特殊作用,只是表示取什么都一样。

COUNT(*)

----------

8

结果明显不同,问题就出在MGR=null的那条数据上。任何值X not in (null) 结果都不成立。

用一个小例子试验一下:

select * from dual where dummy not in ( NULL ) -- no rows selected

select * from dual where NOT( dummy not in ( NULL ) ) --no rows selected

知觉上这两句SQL总有一句会取出数据的,但是实际上都没有。SQL 中逻辑表达式的值可以有三种结果(true false null)而null相当于false.

第3章部分习题与解答

第三章习题 4 .针对上题中建立的四个表试用SQL语言完成第2章习题5中的查询。 答案: (1)求供应工程J1零件的供应商号码SNO; SELECT SNO FROM SPJ WHERE JNO=‘J1’; (2)求供应工程J1零件P1的供应商号码SNO; SELECT SNO FROM SPJ WHERE JNO=‘J1’AND PNO=‘P1’; (3)求供应工程J1零件为红色的供应商号码SNO; SELECT SNO /*这是嵌套查询*/ FROM SPJ WHERE JNO=‘J1’AND PNO IN /*找出红色的零件的零件号码PNO */ (SELECT PNO FROM P /*从P表中找*/ WHERE COLOR=‘红’); 或SELECT SNO FROM SPJ,P /*这是两表连接查询*/ WHERE JNO=‘J1’/*这是复合条件连接查询*/ AND SPJ.PNO=P.PNO AND COLOR=‘红’; (4)求没有使用天津供应商生产的红色零件的工程号JNO; *解析:第一种解法是使用多重嵌套查询,第二种方法的子查询是一个多表连接。 注意:从J表入手,以包含那些尚未使用任何零件的工程号。 SELECT JNO FROM J WHERE NOT EXISTS (SELECT * FROM SPJ WHERE SPJ.JNO=J.JNO AND SNO IN /*天津供应商的SNO*/ (SELECT SNO FROM S WHERE CITY=‘天津’) AND PNO IN /*红色零件的PNO*/ (SELECT PNO FROM P WHERE COLOR=‘红’)); 或SELECT JNO FROM J WHERE NOT EXISTS (SELECT * FROM SPJ, S, P WHERE SPJ.JNO=J.JNO AND SPJ.SNO=S.SNO AND SPJ.PNO=P.PNO AND S.CITY=‘天津’AND P. COLOR=‘红’); //注:本例中父查询和子查询均引用了Student表,可以像自身连接那样用别名将父查询中的Student表与子查询中的Student表区分开:// (5)求至少用了供应商S1所供应的全部零件的工程号JNO (类似于P113例44)。 解析:它所表达的语义为:不存在这样的零件y,供应商S1供应了y,而工程x 没有选用y。 用SQL语言表示如下:

exists的使用(查询选择了所有课程的学生信息)

如何理解多个exists sql(查询选修了全部课程的学生姓名) 查询选修了全部课程的学生姓名 student、sc、course 三张表查询如下: 注:exists是用来判断是否存在的,当exists(查询)中的查询存在结果时则返回真,否则返回假。not exists则相反。 exists做为where 条件时,是先对where 前的主查询询进行查询,然后用主查询的结果一个一个的代入exists的查询进行判断,如果为真则输出当前这一条主查询的结果,否则不输出。 解一: select sname from student where not exists (select * from course wher e not exists (select * from sc where cno = https://www.360docs.net/doc/108071578.html,o and sno=student.s no)) 上面这个列子,先查询出student表的结果,然后将结果代入到student.sno然后再查询出c表中的结果,再一条一条的代入,感觉有点像for的嵌套循环,第一轮外循环中,满足内部的not exists条件的course表中的结果集被保留,然后再判断外部的not exists,这次判断是根据内部Course表中被保留的结果集的情况,如果结果集为空,则输出当前这一条S表的结果集;然后再进行第二轮大的循环,即取出student表的第二条结果代入运算。 以上的sql还可以这样理解,最内部的 select * from sc where cno = https://www.360docs.net/doc/108071578.html,o and sno=student.sno是查询出所有已经选择过课程的学生及相应课程,select * fro m course where not exists 则是所有没有被选择的课程,在这个基础上的select s name from student where not exists 则是选取所有没有未选择课程的学生,即选择了所有课程的学员名称。 解二:

List 基本用法总结

C#泛型列表List基本用法总结 朱先忠 示例代码如下: namespace SampleListT { class Program { static void Main(string[] args) { //using System.Collections.Generic; 命名空间中的List //using System.Collections;命名空间中的ArrayList //都实现了列表集合,一个是泛形集合,一个是非泛型的 //下面我们将Person对象加到集合中 Person p1 = new Person( "aladdin" , 20 ); Person p2 = new Person("zhao", 10); Person p3 = new Person("jacky", 40); //如果不制定list的容器大小,默认是0,只要有元素加入是,会自动扩展到4,如果第5个元素加 入时,就变成了8,第9个加入,就成16 //可以看出,总是成倍的增长,扩展时要重新开辟内存,这样会影响效率,如果事先知道元素个 数,或者可能个数,最好给个尽量大的权衡值 //我们加入3个元素,设容器大小为4.注:设为4不是指只能放4个元素,如果超出,一样也会成倍扩展,这样做只是为了尽量扩展带来的开销 List list = new List(4); list.Add(p1); list.Add(p2); list.Add(p3);

//本方法是清除多于的没有用的内存空间,例:如果开辟大小为100,而我们只用了4个,其余 的放着,是不是很浪费 //本方法调用时会检查元素个数是不是占到了容器大小的90%以上,如果是,则不进行回收. list.TrimExcess(); //ArrayList方法与List<>用法一样,不同的是,它是对象集合,参数是Object这样会有装箱拆 箱的可能,尽量用List<> //本处不再做演示 // 1 初始化集合器 // C#3.0开始,提供了初始化功能,但是并没有反应到IL代码中,在IL中,一样也是把个转 化成ADD方法来调用 List l2 = new List() { 1 ,2 ,3 ,4 ,5 }; // 2 添加元素AddRange() 本方法可以一次性添加一批对象 List lists = new List(10); //参数是一个必须可能跌代的对象,也可是数组 list.AddRange( new Person[] { new Person( "aladdin" ,20) , new Person("zhao",6)}); //构造传入批量参数,与AddRange效果一样 List mylist = new List(new Person[] { new Person( "aladdin" ,20) , new Person("zhao",6)}); // 3 插入元素 // 使用Insert()方法,可以在指定位置插入元素 // 例我们在1位置插入则最后变成了aladdin jacky zhao..插入意思就是,这个位我占了,以前 占这位的和他之后的,通通往后移一位 mylist.Insert( 1 , new Person( "jacky" , 88 ));

2021年高考英语高频考查主题素材词分类记——健康与饮食

2021年高考英语高频考查主题素材词分类记——健康与饮食 话题二健康与饮食 1 高频单词 ·Group 1· 1. allergicadj. 过敏的 2. achevi. &n. 疼痛 3. appetiten. 食欲, 胃口 4. appropriateadj. 合适的, 恰当的 5. balancen. 平衡 6. benefitn. &v. 利益, 受益 7. bleedvi. 出血, 流血 8. cafeterian. 自助餐厅 9. candy n. 糖果 10. canteen n. 餐厅; 食堂 ·Group 2· 1. comfortableadj. 舒服的, 安逸的 2. curen. &vt. 治疗; 治好 3. deliciousadj. 美味的, 可口的 4. desperateadj. 绝望的, 拼命的

5. dietn. 日常饮食; vi. 节食 6. diseasen. 疾病 7. dizzyadj. 头晕目眩的 8. energyn. 精力; 活力 9. harmn. &v. 伤害; 损伤 harmfuladj. 有害的; 致伤的harmlessadj. 无害的; 不致伤的 10. healthn. 健康, 卫生 healthyadj. 健康的, 健壮的 ·Group 3· 1. injurevt. 伤害, 损害 2. necessaryadj. 必需的, 必要的 3. nutritionn. 营养, 滋养 4. operatev. 做手术, 运转;实施, 经营, 管理operationn. 手术, 操作 5. overweightadj. 太胖的, 超重的 6. painfuladj. 痛苦的 7. patientn. 病人 8. physiciann. 内科医生 9. poisonn. 毒药 10. preionn. 处方 ·Group 4·

Oracle SQL NOT EXISTS用法

Oracle SQL NOT EXISTS用法 (1)查询所有未选修“19980201”号课程的学生姓名和班号。 SELECT Sname,classno FROM Student WHERE NOT EXISTS (SELECT * FROM SC WHERE Sno=Student.Sno AND schoolno ='19980201') 运行结果如图所示。 (2)查询选修了全部课程的学生姓名和班号。 分析:本例可转为查询没有一门课程不选的学生姓名和班号,代码如下: SELECT Sname,classno FROM Student WHERE NOT EXISTS (SELECT * FROM Sc WHERE NOT EXISTS (SELECT * FROM school WHERE NOT EXISTS (SELECT * FROM Course WHERE Cno=https://www.360docs.net/doc/108071578.html,o AND school.Schoolno=sc.Schoolno AND sc.Sno=Student.Sno))); 运行结果如图所示。 NOT EXISTS用法(1)NOT EXISTS用法(2) (3)查询至少选修了学生19980001选修的全部课程的学生编号和姓名。 分析:本题的查询要求可做如下解释,查询这样的学生,凡是19980001选修的课,他都选修了;换句话说,若有一个学号为x的学生,对所有课程y,只要学号为19980001的学生选修了课程y,则x也选修了y;那么就将他的学号选出来。 SELECT DISTINCT sno FROM SC SCX WHERE NOT EXISTS (SELECT * FROM SC SCY WHERE SCY .Sno='19980002' AND NOT EXISTS (SELECT * FROM SC SCZ WHERE SCZ .Sno= SCX .Sno AND SCZ.Schoolno=SCY.Schoolno)); 运行结果如图所示。 NOT EXISTS用法(3)

江苏专转本英语真题和答案解析

江苏专转本英语真题和答 案解析 It was last revised on January 2, 2021

江苏省2017年普通高校专转本选拔考试 英语试题卷 注意事项: 1.本试卷分为试题卷和答题卡两部分,试题卷共 10 页,全卷满分 150 分,考试时间 120 分钟。 2.必须在答疑卡上作答,作答在试题卷上无效。作答前务必将自己的姓名和准考正好准确 清晰的填写在试题卷和答题卡上的指定位置。 考试结束时,须将试题卷和答题卡一并交回。 Prat I Reading Comprehension (共 20 小题,每小题 2 分,共 40 分) Directions: There are 4 passage in this part . Each passage is followed by some questions or unfinished statements . For each of them there are 4 choices marked A,B,C and D. You should decide on the best choice and mark your answer by blackening the corresponding letter on the Answer Sheet . Passage One Questions 1 to 5 based on the following passage . We use both words and gestures to express our feelings ,but the problem is that these words and gestures can be understood in different ways . It is true that a smile means the same thing in any language . So does laughter or crying . There are also a number of striking similarities in the way different animals show the same feelings . Dogs , tigers and humans , for example , often show their teeth when they are angry . This is probably because they are born with those behavior patterns . Fear is another emotion that is shown in much the same way all over the world . In Chinese and English literature , a phrase like “he went pale and began to tremble”suggests that the man is either very afraid or deeply shocked . However , “he opened his eyes wide ” is used to suggest anger in Chinese whereas in English it means surprise . In Chinese surprise can be described in a phrase like “they stretched out their tongues ”. Sticking out your tongue in English is an insulting gesture or expresses strong dislike . Even in the same culture , people differ in the ability to understand and express feelings Experiments in America have shown that women are usually better than men at recognizing fear ,anger love and happiness on people’s faces . Other studies show that older people usually find it easier to recognize or understand body language than younger people do . to the passage , _________.

with用法

介詞with用法詳解 是一個十分有用的介詞,其用法也比較複雜,以下用法值得注意: 1. 表示方式、手段或工具等時(=以,用),注意不要受漢語意思的影響而用錯搭配,如「用英語」習慣上用in English,而不是with English。 2. 與某些抽像名詞連用時,其作用相當於一個副詞。如: with care=carefully 認真地 with kindness=kindly 親切地 with joy=joyfully 高興地 with anger=angrily 生氣地 with sorrow=sorrowfully 悲傷地 with ease=easily 容易地 with delight=delightedly 高興地 with great fluency =very fluently 很流利地 3. 表示條件時,根據情況可與虛擬語氣連用。如: With more money I would be able to buy it. 要是錢多一點,我就買得起了。 With better equipment, we could have finished the job even sooner. 要是設備好些,我們完成這項工作還要快些。 4. 比較with和as:兩者均可表示「隨著」,但前者是介詞,後接名詞或代詞;後者是連詞,用於引導一個句子。比較: He will improve as he grows older. 隨著年齡的增長,他會進步的。

People’s ideas change with the change of the times. 時代變了,人們的觀念也會變化。 5. 復合結構「with+賓語+賓語補足語」是一個很有用的結構,它在句中主要用作狀語,表示伴隨、原因、時間、條件、方式等;其中的賓語補足語可以是名詞、形容詞、副詞、現在分詞、過去分詞、不定式、介詞短語等。如: (1) with+賓語+形容詞 He often sleeps with the windows open. 他常開著窗睡覺。 Don’t speak with your mouth full. 不要滿嘴巴食物說話。 (2) with+賓語+ 副詞 He stood before his teacher with his head down. 他低著頭站在老師面前。 He was lying on the bed with all his clothes on. 他和衣躺在床上。 (3) with +賓語+ 介詞短語 She said good-bye with tears in her eyes. 她含著眼淚說了聲再見。 The man was asleep with his head on his arms. 這個人頭枕著胳膊睡著了。 (4) with+賓語+現在分詞 He fell asleep with the lamp burning. 他沒熄燈就睡著了。 I won’t be able to go on holiday with my mother being ill. 因為媽媽有病, 我無 法去度假。 (5) with +賓語+ 過去分詞 He sat there with his eyes closed. 他閉目坐在那兒。 All the afternoon he worked with the door locked. 整個下午他都鎖著門在房裡

oracle中的exists 和not exists 用法

oracle中的exists 和not exists 用法 有两个简单例子,以说明“exists”和“in”的效率问题 Java代码 1) select * from T1 where exists(select 1 from T2 where T1.a=T2.a) ; T1数据量小而T2数据量非常大时,T1<>T2 时,2) 的查询效率高。 class=java style="DISPLAY: none" name="code"1) select * from T1 where exists(select 1 from T2 where T1.a=T2.a) ; T1数据量小而T2数据量非常大时,T1<>T2 时,2) 的查询效率高。 exists 用法: 请注意1)句中的有颜色字体的部分,理解其含义; 其中 Java代码 “select 1 from T2 where T1.a=T2.a” class=java style="DISPLAY: none" name="code"“select 1 from T2 where T1.a=T2.a”相当于一个关联表查询,相当于

Java代码 “select 1 from T1,T2 where T1.a=T2.a” class=java style="DISPLAY: non e" name="code"“select 1 from T1,T2 where T1.a=T2.a” 但是,如果你当当执行1)句括号里的语句,是会报语法错误的,这也是使用exists需要注意的地方。 “exists(xxx)”就表示括号里的语句能不能查出记录,它要查的记录是否存在。 因此“select 1”这里的“1”其实是无关紧要的,换成“*”也没问题,它只在乎括号里的数据能不能查找出来,是否存在这样的记录,如果存在,这1)句的where 条件成立。 in 的用法: 继续引用上面的例子 Java代码 select * from T1 where T1.a in (select T2.a from T2) ” class=java style="DISPLAY: none" name="code"select * from T1 where T1.a in (select T2.a from T2) ” 这里的“in”后面括号里的语句搜索出来的字段的内容一定要相对应,一般来说,T1和T2这两个表的a字段表达的意义应该是一样的,否则这样查没什么意义。 打个比方:T1,T2表都有一个字段,表示工单号,但是T1表示工单号的字段名叫“ticketid”,T2则为“id”,但是其表达的意义是一样的,而且数据格式也是一样的。这时,用2)的写法就可以这样: Java代码 “select * from T1 where T1.ticketid in (select T2.id from T2) ” Select name from employee where name not in (select name from student); Select name from employee where not exists (select name from student); class=java style="DISPLA Y: none" name="code"“select * from T1 where T1.ticketid in (select T2.id from T2) ”

SQL中exist与in的区别

SQL中exist与in的区别 in 是一个集合运算符. a in {a,c,d,s,d....} P105例子 这个运算中,前面是一个元素,后面是一个集合,集合中的元素类型是和前面的元素一样的. 而exists是一个存在判断,如果后面的查询中有结果,则exists为真,否则为假. in 运算用在语句中,它后面带的select 一定是选一个字段,而不是select *. 比如说你要判断某班是否存在一个名为"小明"的学生,你可以用in 运算: "小明" in (select sname from student) 这样(select sname from student) 返回的是一个全班姓名的集合,in用于判断"小明"是否为此集合中的一个数据; 同时,你也可以用exists语句: exists (select * from student where sname="小明") select * from 表A where exists(select * from 表B where 表B.id=表A.id) 这句相当于 select * from 表A where id in (select id from 表B) 对于表A的每一条数据,都执行select * from 表B where 表B.id=表A.id的存在性判断,如果表B中存在表A当前行相同的id,则exists为真,该行显示,否则不显示 区分in和exists主要是造成了驱动顺序的改变(这是性能变化的关键),如果是exists,那么以外层表为驱动表,先被访问,如果是IN,那么先执行子查询 IN适合于外表大而内表小的情况;EXISTS适合于外表小而内表大的情况。

重要单词用法

bid/b?d/CET4 TEM4( bidding, bids ) 1. N-COUNT A bid for something or a bid to do something is an attempt to obtain it or do it. 努力尝试[journalism]例: ...Sydney's successful bid for the 2000 Olympic Games. …悉尼对2000年奥林匹克运动会成功的申办。 2. N-COUNT A bid is an offer to pay a particular amount of money for something that is being sold. 出价 例: Hanson made an agreed takeover bid of $351 million. 汉森按约定出价3.51亿美元进行收购。 3. V-T/V-I If you bid for something or bid to do something, you try to obtain it or do it. 力求获得; 努力争取 例: Singapore Airlines is rumoured to be bidding for a management contract to run both airports. 据传,新加坡航空公司正在努力争取这两个机场的管理合约。 4. V-I If you bid for something that is being sold, you offer to pay a particular amount of money for it. 出价 例: She wanted to bid for it. 她想出价买下它。 例: The bank announced its intention to bid. 银行宣布了其投标意向。 blunder/?bl?nd?/CET6 TEM8( blundering, blundered, blunders ) 1. N-COUNT A blunder is a stupid or careless mistake. 愚蠢错误 例: I think he made a tactical blunder by announcing it so far ahead of time. 我认为他如此提早宣布消息是犯了战术上的错误。 2. V-I If you blunder, you make a stupid or careless mistake. 犯愚蠢错误 例: No doubt I had blundered again. 不用说我又犯了个蠢错。 3. V-I If you blunder into a dangerous or difficult situation, you get involved in it by mistake. 误入(危险境地或困境) 例: People wanted to know how they had blundered into war, and how to avoid it in the future. 人们想弄清他们怎么会错误地卷入战争,将来如何才能避免这样的事。 4. V-I If you blunder somewhere, you move there in a clumsy and careless way. 跌跌撞撞地走 例: He had blundered into the table, upsetting the flowers. 他撞上了桌子,打翻了花。 cater/?ke?t?/CET6 TEM4( catering, catered, caters )

跨文化交际期末复习

判断 1 the iceberg model of culture implies that it is very difficult to understand a culture thoroughly 文化的冰山模式意味着要彻底理解文化是非常困难的。(T ) 2 culture is innate as soon as a person is born 一个人出生就有文化(F )3 people may sometimes get confused about his or her cultural identity 人们有时会对他或她的文化身份感到困惑。(T )4 scholars prefer the term subculture to co-culture in describing a culture which exists witnin a dominant culture 在描述一种存在显性文化的文化时,学者们倾向于亚文化到共同文化。(F )5 a person could be a member of several different subgroups at the same time 一个人可以同时成为几个不同的子组的成员。(T )6 Intracultural communication occurs when the sender and the receiver from different races exchang messages 文化的交流是发生在不同种族交换消息的发送者和接收者(F )7 communication and culture are inseparable and strongly connected 沟通与文化密不可分,紧密相连。(T )8 The sender must choose certain words or nonverbal to send an intentional message.this activity is called decoding 发送者必须选择言语或非言语的发出故意这活动被称为解码(F )9 The process of communication has nine components :sender,encoding,message,channel,noise,decoding,feedback,and context 通信过程由九部分组成:发送方、编码、消息、信道、噪声、解码、反馈和上下文。(T )10 No two of us can assume that our sensations are the same 我们谁也不能假定我们的感觉是一样的。(T )11 people may possess different sensing of the same smell 人们可能对同一气味有不同的感觉。(T )12 Our perception are influenced by who we are,includeing the accumulation of our experience 我们的感觉被我们是谁的影响,包括我们的经验的积累(T )13 we give meaning to or decode the information that we have selected and organized during the selection stage 我们在选择阶段对我们选择和组织的信息给予意义或解码。(F )14 the psychological filters refer to the psychological factors,including the attitudes,beliefs,and dispositions of the individual 心理过滤指的是心理因素,包括个人的态度、信念和性格。(T )15 ethnocentrism,stereotyping,prejudice and racism are learned 民族中心主义、刻板印象、偏见和种族主义被学习(T )16 although stereotypes are considered as being negative judgements,they can also be positive 虽然刻板印象被认为是消极的判断,但也可以是积极的。(T )17 when communicating with people from other cultures,an individual sometimes is likely to treat them as his people and to assume there is only one way of doing things:that is his way 当与来自其他文化的人交流时,一个人有时可能会把他们当作他的人看待,并假设只有一种做事方式:那就是他的方式。(T )18 assumption of superiority may lead to asuming similarity instead of difference

with用法

with结构是许多英语复合结构中最常用的一种。学好它对学好复合宾语结构、不定式复合结构、动名词复合结构和独立主格结构均能起很重要的作用。本文就此的构成、特点及用法等作一较全面阐述,以帮助同学们掌握这一重要的语法知识。 一、with结构的构成 它是由介词with或without+复合结构构成,复合结构作介词with或without的复合宾语,复合宾语中第一部分宾语由名词或代词充当,第二部分补足语由形容词、副词、介词短语、动词不定式或分词充当,分词可以是现在分词,也可以是过去分词。With结构构成方式如下: 1. with或without-名词/代词+形容词; 2. with或without-名词/代词+副词; 3. with或without-名词/代词+介词短语; 4. with或without-名词/代词+动词不定式; 5. with或without-名词/代词+分词。 下面分别举例: 1、She came into the room,with her nose red because of cold.(with+名词+形容词,作伴随状语) 2、With the meal over ,we all went home.(with+名词+副词,作时间状语) 3、The master was walking up and down with the ruler under his arm。(with+名词+介词短语,作伴随状语。)The teacher entered the classroom with a book in his hand. 4、He lay in the dark empty house,with not a man ,woman or child to say he was kind to me.(with+名词+不定式,作伴随状语)He could not finish it without me to help him.(without+代词+不定式,作条件状语) 5、She fell asleep with the light burning.(with+名词+现在分词,作伴随状语) 6、Without anything left in the cupboard,she went out to get something to eat.(without+代词+过去分词,作为原因状语) 二、with结构的用法 在句子中with结构多数充当状语,表示行为方式,伴随情况、时间、原因或条件(详见上述例句)。

数据库系统概论试题及答案

试题二 一、单项选择题 在每小题列出的四个备选项中只有一个是符合题目 要求的,请将其代码填写在题后的括号内。错选、 多选或未选均无分。 1. 下列四项中,不属于数据库系统的主要特点的是()。 A.数据结构化B.数据的冗余度小 C.较高的数据独立性 D.程序的标准化 2. 数据的逻辑独立性是指() A.内模式改变,模式不变 B.模式改变,内模式不变 C.模式改变,外模式和应用程序不变 D.内模式改变,外模式和应用程序不变 3. 在数据库的三级模式结构中,描述数据库中全体数据的全局逻辑结构和特征 的是()。 A.外模式 B.内模式 C.存储模式 D.模式 4. 相对于非关系模型,关系数据模型的缺点之一是()。 A.存取路径对用户透明,需查询优化 B.数据结构简单 C.数据独立性高D.有严格的数学基础 5. 现有关系表:学生(宿舍编号,宿舍地址,学号,姓名,性别,专业,出生 日期)的主码是()。 A.宿舍编号 B.学号 C.宿舍地址,姓名 D.宿舍编号,学号 6.自然连接是构成新关系的有效方法。一般情况下,当对关系R和S使用自然 连接时,要求R和S含有一个或多个共有的()。 A.元组 B.行 C.记录 D.属性 7.下列关系运算中,()运算不属于专门的关系运算。 A.选择B.连接 C.广义笛卡尔积D.投影 8. SQL语言具有()的功能。

A.关系规范化、数据操纵、数据控制 B.数据定义、数据操纵、数据控制 C.数据定义、关系规范化、数据控制 D.数据定义、关系规范化、数据操纵 9.从E-R模型关系向关系模型转换时,一个M:N联系转换为关系模式时,该关系模式的关键字是()。 A.M端实体的关键字B.N端实体的关键字 C.M端实体关键字与N端实体关键字组合 D.重新选取其他属性 10. SQL语言中,删除一个表的命令是() A. DELETE B. DROP C. CLEAR D. REMOVE 11. 图1中()是关系完备的系统 A B C D 图1 12.有关系模式A(S,C,M),其中各属性的含义是:S:学生;C :课程;M:名次,其语义是:每一个学生选修每门课程的成绩有一定的名次,每门课程中每一名次只有一个学生(即没有并列名次),则关系模式A最高达到()A.1NF B.2NF C.3NF D.BCNF 13.关系规范化中的删除异常是指 ( ) A.不该删除的数据被删除B.不该插入的数据被插入C.应该删除的数据未被删除D.应该插入的数据未被插入 14.在数据库设计中, E-R图产生于() A.?需求分析阶段?? B.物理设计阶段??? C.逻辑设计阶段??? D.概念设计阶段 15.有一个关系:学生(学号,姓名,系别),规定学号的值域是8个数字组成的字符串,这一规则属于()。 A.实体完整性约束 B.参照完整性约束 C.用户自定义完整性约束 D.关键字完整性约束

EXISTS的用法

EXISTS 指定一个子查询,检测行的存在。 语法 EXISTS subquery 参数 subquery 是一个受限的SELECT 语句(不允许有COMPUTE 子句和INTO 关键字)。有关更多信息,请参见SELECT 中有关子查询的讨论。 结果类型 Boolean 结果值 如果子查询包含行,则返回TRUE。 示例 A. 在子查询中使用NULL 仍然返回结果集 这个例子在子查询中指定NULL,并返回结果集,通过使用EXISTS 仍取值为TRUE。 USE Northwind GO SELECT CategoryName FROM Categories WHERE EXISTS (SELECT NULL) ORDER BY CategoryName ASC GO B. 比较使用EXISTS 和IN 的查询 这个例子比较了两个语义类似的查询。第一个查询使用EXISTS 而第二个查询使用IN。注意两个查询返回相同的信息。 USE pubs GO SELECT DISTINCT pub_name FROM publishers WHERE EXISTS (SELECT * FROM titles WHERE pub_id = publishers.pub_id AND type = 'business')

GO -- Or, using the IN clause: USE pubs GO SELECT distinct pub_name FROM publishers WHERE pub_id IN (SELECT pub_id FROM titles WHERE type = 'business') GO 下面是任一查询的结果集: pub_name ---------------------------------------- Algodata Infosystems New Moon Books (2 row(s) affected) C.比较使用EXISTS 和= ANY 的查询 本示例显示查找与出版商住在同一城市中的作者的两种查询方法:第一种方法使用= ANY,第二种方法使用EXISTS。注意这两种方法返回相同的信息。 USE pubs GO SELECT au_lname, au_fname FROM authors WHERE exists (SELECT * FROM publishers WHERE authors.city = publishers.city) GO -- Or, using = ANY USE pubs GO SELECT au_lname, au_fname FROM authors WHERE city = ANY

相关文档
最新文档