exists

【数据库】相关代码集

ε祈祈猫儿з 提交于 2020-01-21 15:04:57
1 Create Table student 2 ( 3 Sno char (9) Primary key , 4 Sname char (20) Unique , 5 Ssex char (2) , 6 Sage smallint , 7 Sdept char(20) 8 9 ); 10 11 Create Table Course 12 ( 13 Cno char (4) Primary key , 14 Cname char (40) not Null , 15 Cpno char (4) , 16 Ccredit smallint 17 foreign key (Cpno) References Course(Cno) 18 ); 19 20 Create Table SC 21 ( 22 Sno char (9) , 23 Cno char (4) , 24 Grade smallint 25 26 Primary key ( Sno , Cno ) , 27 Foreign key ( Sno ) References Student (Sno), 28 Foreign key ( Cno ) References Course (Cno) 29 30 ); 31 32 Insert Into student(Sno,Sname,Ssex,Sage,Sdept) 33

Android: How to detect a directory in the assets folder?

陌路散爱 提交于 2020-01-21 05:22:08
问题 I'm retrieving files like this String[] files = assetFiles.list("EngagiaDroid"); How can we know whether it is a file or is a directory? I want to loop through the directories in the assets folder then copy all of its contents. 回答1: You can check if a File represents a directory using http://developer.android.com/reference/java/io/File.html#isDirectory(). Is that what you mean? 回答2: I think a more general solution (in case you have subfolders etc.) would be something like this (based on the

Mysql 存储过程查询结果赋值到变量的方法

喜欢而已 提交于 2020-01-21 00:06:21
drop table if exists test_tbl; create table test_tbl (name varchar(20), status int(2)); insert into test_tbl values('abc', 1),('edf', 2),('xyz', 3); drop procedure IF EXISTS pro_test_3; delimiter // create procedure pro_test_3() begin -- 方式 1 DECLARE cnt INT DEFAULT 0; select count(*) into cnt from test_tbl; select cnt; -- 方式 2 set @cnt = (select count(*) from test_tbl); select @cnt; -- 方式 3 select count(*) into @cnt1 from test_tbl; select @cnt1; -- 多个列的情况下似乎只能用 into 方式 select max(status), avg(status) into @max, @avg from test_tbl; select @max, @avg; end // delimiter ; call pro_test_3();    来源

Zookeeper 初体验之——JAVA实例

二次信任 提交于 2020-01-19 06:30:15
简介 Apache Zookeeper 是由 Apache Hadoop 的 Zookeeper 子项目发展而来,现在已经成为了 Apache 的顶级项目。Zookeeper 为分布式系统提供了高效可靠且易于使用的协同服务,它可以为分布式应用提供相当多的服务,诸如统一命名服务,配置管理,状态同步和组服务等。 Zookeeper 接口简单,开发人员不必过多地纠结在分布式系统编程难于处理的同步和一致性问题上,你可以使用 Zookeeper 提供的现成(off-the-shelf)服务来实现分布式系统的配置管理,组管理,Leader 选举等功能。 英文原文地址 : http://zookeeper.apache.org/doc/current/javaExample.html 一个简单的 Zookeeper Watch 客户端 为了介绍 Zookeeper Java API 的基本用法,本文将带你如何一步一步实现一个功能简单的 Zookeeper 客户端。该 Zookeeper 客户端会监视一个你指定 Zookeeper 节点 Znode, 当被监视的节点发生变化时,客户端会启动或者停止某一程序。 基本要求 该客户端具备四个基本要求: 客户端所带参数: Zookeeper 服务地址。 被监视的 Znode 节点名称。 可执行程序及其所带的参数 客户端会获取被监视 Znode

三种方法解决 Job for network.service failed. See 'systemctl status network.service' and 'journalctl -xn'问题

半城伤御伤魂 提交于 2020-01-19 00:42:26
Failed to start LSB: Bring up/down networking 问题 1、执行 service network restart 出现以下错误 Restarting network ( via systemctl ) : Job for network.service failed. See 'systemctl status network.service' and 'journalctl -xn' for details. 2、根据上面的提示,执行“systemctl status network.service”输出以下的类似信息: [ root@localhost ~ ] # systemctl status network.service network.service - LSB: Bring up/down networking Loaded: loaded ( /etc/rc.d/init.d/network ) Active: failed ( Result: exit-code ) since三 2014-11-05 15:30:10 CST ; 1min 5s ago 11月 05 15:30:10 localhost.localdomain network [ 2920 ] : RTNETLINK answers: File

Python,exists判断文件是否存在

若如初见. 提交于 2020-01-18 22:26:12
命令 exists: 文件名字符串作为参数,如果文件存在的话,它将返回 True,否则将返回 False。 # -- coding: utf-8 -- from sys import argv # 导入函数或者模块 from os.path import exists (script, from_file, to_file) = argv # 解包 print("Copying from %r to %r" % (from_file, to_file)) inputfile = open(from_file) indata = inputfile.read() print("The input file is %d bytes long" % len(indata)) print("the file content: %r" % indata) print("Does the output file exist? %r" % exists(to_file)) # 判断文件存在 print("Ready, hit RETURN to continue, CTRL-C to abort.") input() outputfile = open(to_file, 'w') # 以写的方式打开文件 outputfile.write(indata) # 写入数据 print("Alright

How can I check if a stored procedure exists in PERVASIVE database before creating it?

戏子无情 提交于 2020-01-17 06:01:08
问题 I want to create a stored procedure in a Pervasive database, but only if it does not yet exist. I found something for SQL Server: IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND OBJECT_ID = OBJECT_ID('dbo.MyProc')) exec('CREATE PROCEDURE [dbo].[MyProc] AS BEGIN SET NOCOUNT ON; END') GO I found that code on this link How to check if a stored procedure exists before creating it. So I want something really similar for Pervasive. 回答1: There's no way to execute the IF NOT EXISTS

MySQL/PHP/PDO + How to get a row for each (duplicate) entry in IN() clasue?

感情迁移 提交于 2020-01-17 01:05:18
问题 Language: PHP DB: MySQL My understanding is that if you have duplicate entries in the IN() clause.. they will be skipped... I need a return/row for each item in the IN() clause.. regardless if they are dups or not. From reading... I believe a [self] JOIN() is the approach/solution I am looking for.. but I am not clear on how to do this JOIN on the same table? .. especially with the query I already have going below. (which works how I need it to.. expect for not returning a row for the

MySQL/PHP/PDO + How to get a row for each (duplicate) entry in IN() clasue?

让人想犯罪 __ 提交于 2020-01-17 01:01:12
问题 Language: PHP DB: MySQL My understanding is that if you have duplicate entries in the IN() clause.. they will be skipped... I need a return/row for each item in the IN() clause.. regardless if they are dups or not. From reading... I believe a [self] JOIN() is the approach/solution I am looking for.. but I am not clear on how to do this JOIN on the same table? .. especially with the query I already have going below. (which works how I need it to.. expect for not returning a row for the

统计2张表中不相同的数据

社会主义新天地 提交于 2020-01-16 20:53:13
统计2张表中不相同的数据 参考 SQL中EXISTS的用法 Sql 语句中 IN 和 EXISTS 的区别及应用 MySQL的语句执行顺序 sql逻辑执行顺序 需求 查出了某段时间的系统中微信用户的openId和这段时间之前的系统中所有微信用户的openId,根据这2张表统计出这段时间新增的微信用户数量和这段时间内老的微信用户的数量。 思路 表1:这段时间的系统中微信用户的openId 表2:这段时间之前系统中所有微信用户的openId 新增的微信用户数量:查询在表1但是不在表2的openId的数量。 老的微信用户的数量:查询出同时在表1和表2的openId的数量。 统计sql 方式一 not in SELECT * FROM user1 WHERE openId NOT IN (SELECT openId FROM user2) 方式二 表连接 SELECT U1.* FROM user1 AS U1 LEFT JOIN user2 AS U2 ON U1.openId = U2.openId WHERE U2.openId IS NULL 方式三 相关子查询 如果子查询的条件中使用了其外层的表的字段,这种子查询就叫作相关子查询。相关子查询可以用IN、NOT IN、EXISTS、NOT EXISTS引入。 这种方式先查询出外表中的数据,然后将外表中的数据作为条件。