exists

数据库实验三

走远了吗. 提交于 2019-12-07 22:38:20
--(一)以数据库系统实验1中student数据库为基础,请使用T-SQL 语句实现进行以下操作: --1.查询以‘DB_’开头,且倒数第3个字符为‘s’的课程的详细情况; select * from course where cname like 'DB[_]%'and SUBSTRING(cname,len(cname)-2,1)='s' --2.查询名字中第2个字为‘阳’的学生姓名和学号及选修的课程号、课程名; select student.sname,student.sno,course.cno,course.cname from course,sc,student WHERE SUBSTRING(student.sname,2,1)='阳'and student.sno=sc.sno and sc.cno = course.cno --3.列出选修了‘数学’或者‘大学英语’的学生学号、姓名、所在院系、选修课程号及成绩; select student.sname,student.sno,student.sdept,course.cno,sc.grade from course,sc,student WHERE course.cno=sc.cno and student.sno=sc.sno and (course.cname='数学' or course.cname=

基于OGG的Oracle与Hadoop集群准实时同步介绍

房东的猫 提交于 2019-12-07 19:01:03
版权声明:本文由王亮原创文章,转载请注明出处: 文章原文链接: https://www.qcloud.com/community/article/220 来源:腾云阁 https://www.qcloud.com/community Oracle里存储的结构化数据导出到Hadoop体系做离线计算是一种常见数据处置手段。近期有场景需要做Oracle到Hadoop体系的实时导入,这里以此案例做以介绍。 Oracle作为商业化的数据库解决方案,自发性的获取数据库事务日志等比较困难,故选择官方提供的同步工具OGG(Oracle GoldenGate)来解决。 安装与基本配置 环境说明 软件配置 角色 数据存储服务及版本 OGG版本 IP 源服务器 OracleRelease11.2.0.1 Oracle GoldenGate 11.2.1.0 for Oracle on Linux x86-64 10.0.0.25 目标服务器 Hadoop 2.7.2 Oracle GoldenGate for Big Data 12.2.0.1 on Linux x86-64 10.0.0.2 以上源服务器上OGG安装在Oracle用户下,目标服务器上OGG安装在root用户下。 注意 Oracle导出到异构的存储系统,如MySQL,DB2,PG等以及对应的不同平台,如AIX,Windows

check if a key exist firebase Android

浪子不回头ぞ 提交于 2019-12-07 07:24:08
问题 I want to check if a key exist in the firebase db. so for example, I want to look for the key "upvotes" to see if it exist or not. Here is an exmaple, "upvotes" key does not exist in here: Now I my attempt to check if the key "upvotes" is at this location: Map<String, Object> newPost = (Map<String, Object>) ids.next().getValue(); if(newPost.get("upvotes").toString().equals("upvotes")){ disp_rate = newPost.get("upvotes").toString(); } else { disp_rate = "0"; } My attempt is wrong, so how do I

Additional hash lookup using 'exists'?

◇◆丶佛笑我妖孽 提交于 2019-12-07 04:56:32
问题 I sometimes access a hash like this: if(exists $ids{$name}){ $id = $ids{$name}; } Is that good practice? I'm a bit concerned that it contains two lookups where really one should be done. Is there a better way to check the existence and assign the value? 回答1: By checking with exists , you prevent autovivification. See Autovivification : What is it and why do I care?. UPDATE: As trendels points out below, autovivification does not come into play in the example you posted. I am assuming that the

帮盖尔优化SQL

♀尐吖头ヾ 提交于 2019-12-06 21:47:17
我加了很多ORACLE群,自己本人也很喜欢扯淡。最近经常去 ORACLE酱油群 扯淡,酱油群里有很多大师,还有ORACLE原厂的,神马世界500强的都有。 经常看见盖尔拿个SQL出来吆喝,我这人有个爱好,喜欢优化复杂SQL,对神马统计信息缺失/不准,绑定变量窥探,等等的SQL优化很没兴趣,也对神马聚簇因子很大滴优化也没兴趣,就喜欢搞复杂的SQL,其实优化复杂SQL往往需要改写代码,但是我这个人懒,又偏偏不喜欢改写SQL,总是喜欢给SQL找点性能瓶颈,让他们自己改去 呵呵。 盖尔的那个SQL信息如下: select * from (select rownum as my_rownum, table_a.* from (select e.company_name organ_name, e.abbr_name organ_abbr_name, a.agency_uw_state, a.agency_uw_time, a.ht_bill_def_version, (SELECT version.ht_bill_def_version_type_id FROM t_ht_bill_def_version version WHERE a.ht_bill_def_version = version.ht_bill_def_version) ht_bill_def_version_type_id

Appendix 2- Lebesgue integration and Reimann integration

北城以北 提交于 2019-12-06 16:31:26
Lebesgue integration and Reimann integration : Reimann: Split up the axis into equal intervals, then approximate the function within each interval, add up all of those approximate values, and then let the quantization over the time axis become finer. Lebesgue: Split up the other axis. Start with a zero, quantize into epsilon, 2 epsilon, 3 epsilon and so forth. Making epsilon smaller enough. Lower bound. Rules: l Whenever the Riemann integral exists, the Lebesgue integral also exists and has the same value. l The familiar rules for calculating Riemann integrals also apply for Lebesgue integrals

shell脚本编程之条件判断

ぐ巨炮叔叔 提交于 2019-12-06 13:03:37
条件测试类型: 整数测试 字符测试 文件测试 条件测试的表达式的三种方法: 1、[ expression ] 命令测试 2、[[ expression ]] 关键字测试 3、test expression 整数比较: -eq:测试两个整数是否相等;相等为真,不等为假 -ne:测试两个整数是否不等;不等为真,相等为假 -gt:测试一个数是否大于另一个数;大于为真,否则为假 -lt:测试一个数是否小于另一个数;小于为真,否则为假 -ge:大于或等于 -le:小于或等于 命令间的逻辑关系: !:表示非(取反) 逻辑与:&& 逻辑或:|| CMD1 && CMD2 Example:id aaa && echo "hello aaa" 如果&&前的执行结果是假,总的结果就是假,没必要执行&&后的操作 如果CMD1成功了(真),就可执行CMD2 如果CMD1失败了(假),就不执行CMD2 如果aaa用户存在,则打印hello aaa;如果用户aaa不存在,则不进行打印 CMD1 || CMD2 Example:id aaa || useradd aaa 如果||前的执行结果是真,总的结果就是真,没必要执行||后的操作CMD2 如果CMD1成功了(真),就不执行CMD2 如果CMD1失败了(假),就可执行CMD2 如果用户aaa存在,就不执行创建aaa用户的命令;如果aaa用户不存在

shell脚本编程之条件判断

折月煮酒 提交于 2019-12-06 13:01:58
条件测试类型: 整数测试 字符测试 文件测试 条件测试的表达式的三种方法: 1、[ expression ] 2、[[ expression ]] 3、test expression 整数比较: -eq:测试两个整数是否相等;相等为真,不等为假 -ne:测试两个整数是否不等;不等为真,相等为假 -gt:测试一个数是否大于另一个数;大于为真,否则为假 -lt:测试一个数是否小于另一个数;小于为真,否则为假 -ge:大于或等于 -le:小于或等于 命令间的逻辑关系: !:表示非(取反) 逻辑与:&& 逻辑或:|| CMD1 && CMD2 Example:id aaa && echo "hello aaa" 如果&&前的执行结果是假,总的结果就是假,没必要执行&&后的操作 如果CMD1成功了(真),就可执行CMD2 如果CMD1失败了(假),就不执行CMD2 如果aaa用户存在,则打印hello aaa;如果用户aaa不存在,则不进行打印 CMD1 || CMD2 Example:id aaa || useradd aaa 如果||前的执行结果是真,总的结果就是真,没必要执行||后的操作CMD2 如果CMD1成功了(真),就不执行CMD2 如果CMD1失败了(假),就可执行CMD2 如果用户aaa存在,就不执行创建aaa用户的命令;如果aaa用户不存在,则创建该用户 EXAMPLE:

SQL if exists用法

此生再无相见时 提交于 2019-12-06 12:25:21
判断数据库是否存在 if exists (select * from sys.databases where name = ’数据库名’) drop database [数据库名] 判断表是否存在 if exists (select * from sysobjects where id = object_id(N’[表名]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1) drop table [表名] 判断存储过程是否存在 if exists (select * from sysobjects where id = object_id(N’[存储过程名]’) and OBJECTPROPERTY(id, N’IsProcedure’) = 1) drop procedure [存储过程名] 判断临时表是否存在 if object_id(’tempdb..#临时表名’) is not null drop table #临时表名 判断视图是否存在 --SQL Server 2000 IF EXISTS (SELECT * FROM sysviews WHERE object_id = ’[dbo].[视图名]’ --SQL Server 2005 IF EXISTS (SELECT * FROM sys.views WHERE object

Variables for identifiers inside IF EXISTS in a plpgsql function

落爺英雄遲暮 提交于 2019-12-06 11:28:06
CREATE OR REPLACE FUNCTION drop_now() RETURNS void AS $BODY$ DECLARE row record; BEGIN RAISE INFO 'in'; FOR row IN select relname from pg_stat_user_tables WHERE schemaname='public' AND relname LIKE '%test%' LOOP IF EXISTS(SELECT row.relname.tm FROM row.relname WHERE row.relname.tm < current_timestamp - INTERVAL '90 minutes' LIMIT 1) THEN -- EXECUTE 'DROP TABLE ' || quote_ident(row.relname); RAISE INFO 'Dropped table: %', quote_ident(row.relname); END IF; END LOOP; END; $BODY$ LANGUAGE plpgsql VOLATILE; Could you tell me how to use variables in SELECT which is inside IF EXISTS ? At the present