exists

Java文件操作——File

夙愿已清 提交于 2019-12-25 05:08:47
创建File   isFile()、length()、exists()、createNewFile()、   File.separator /   isDirtory()、 mkdir()、mkdirs()、 delete()、   listFiles()、FileFilter(){}; -------------------------------淫荡分隔---------------------------------- 创建File文件对象 java.io.File用于表示文件(目录),也就是说程序员可以通过File类在程序中操作硬盘上的文件和目录。 File类只用于表示文件(目录)的信息(名称、大小等),换句话说只能访问文件或目录的相关属性,不能对文件的内容进行访问。 public class Filedemo1 { public static void main(String[] args) { // java.io.File 判断是否为文件 File file= new File("./1.txt"); boolean isFile = file.isFile(); if(isFile){ System.out.println("是一个文件"); }else{ System.out.println("不是一个文件"); } /* * 查看文件占用的字节量 注意目录无大小

MySql 和Server Sql的差异

雨燕双飞 提交于 2019-12-25 03:11:21
MySql 和 Server Sql 的差异 1 、自增长列的插入: SQLServer 中可以不为自动增长列插入值, MySQL 中需要为自动增长列插入值。 2 、获取当前时间函数 : SQLServer 写法: getdate() MySQL 写法: now() 3 、从数据库定位到表。 Sqlserver 写法:库名 .dbo. 表名 ;或者:库名 .. 表名 (注:中间使用两个点) select password from Info.dbo.users where userName='boss' 或者 select password from Info..users where userName='boss' mysql 写法:库名 . 表名 select password from Info.users where userName='boss' 4 、判断是否存在某个数据库,若存在,则删除 Sqlserver 写法: IF DB_ID('users') IS NOT NULL DROP DATABASE users Mysql 写法: Drop DATABASEif exists users 拓展:若 sqlserver 数据库正在使用中,删除之前,先要把数据库变成 “ 单一用户 ” ,再删除 ALTER DATABASE users SET SINGLE_USER

Oracle 子查询

血红的双手。 提交于 2019-12-25 02:59:51
子查询可以返回单行结果,可以返回多行结果,也可以不返回结果。 如果子查询未返回任何行,则主查询也不会返回任何结果 (空值)select * from emp where sal > (select sal from emp where empno = 8888); 如果子查询返回单行结果,则为单行子查询,可以在主查 询中对其使用相应的 单行 记录比较运算符 (正常)select * from emp where sal > (select sal from emp where empno = 7566); 如果子查询返回多行结果,则为多行子查询,此时不允许 对其使用单行记录比较运算符 (多值)select * from emp where sal > (select avg(sal) from emp group by deptno);//非法 子查询中常用方法 1。 any即任何一个。如果在where条件中加入>any,意思是大于任何一个,也就是大于最小的 select * from emp t where t.sal> any(select sal from hhgy.emp where deptno=30) 2。 some即一些。和any的用法基本相同。用any的地方都可以用some代替。不过some大多用在=操作中。表示等于所选集合中的任何一个。当然any也可以用于=操作中

Insert Into table If similar value exists in another existing table (not a foreign key)

故事扮演 提交于 2019-12-24 23:11:10
问题 I'm trying to insert an "Item order" in a table called AsksFor and I want to make sure the Item and ItemManufacturer exists in the table Sells. However I keep getting "syntax error, unexpected if, expecting END_OF_INPUT or ';'" for using the IF. Anyone know any other ways to write this for MySQL? INSERT INTO AsksFor (Username, ItemName, ItemManufacturer) VALUES ('Harish', 'zkoxtlv93', 'tbzrt93') IF EXISTS(SELECT ItemName, ItemManufacturer FROM Sells WHERE Sells.ItemName = VALUES(ItemName) AND

How do I condense this?

坚强是说给别人听的谎言 提交于 2019-12-24 10:39:05
问题 It's actually much longer than this. What is the better way to do this? I'm trying to write a decider that looks at files and determines which script to goto. IF EXIST *x71c48* (GOTO script-a) else goto script-b IF EXIST *x72c48* (GOTO script-a) else goto script-b IF EXIST *x73c48* (GOTO script-a) else goto script-b IF EXIST *x74c48* (GOTO script-a) else goto script-b IF EXIST *x75c48* (GOTO script-a) else goto script-b IF EXIST *x76c48* (GOTO script-a) else goto script-b IF EXIST *x77c48*

Correlated query: select where condition not max(condition in inner query)

夙愿已清 提交于 2019-12-23 16:09:05
问题 I am trying to select all the rows where the userName and groupId is duplicated, and the userId is not the max userId for that userName/groupId combination. Here is my code so far: select * from userTable u where exists (select * from userTable u1 where userName <> '' and userName is not null and u.userName = u1.userName and u.groupId = u1.groupId and u.userId <> max(u1.userId) group by userName, groupId having count(*) > 1) order by userName However, the line: and u.userId <> u1.max(userId)

sql server 子查询 和exists使用

不打扰是莪最后的温柔 提交于 2019-12-23 11:38:20
概述 子查询的概念:   当一个查询是另一个查询的条件时,称之为 子查询 。子查询可以嵌套在主查询中所有位置,包括SELECT、FROM、WHERE、GROUP BY、HAVING、ORDER BY。   外面的查询成为 父查询 ,圆括号嵌入的查询成为称为子查询。SQL Server执行时,先执行子查询部分,求出子查询部分的值,再执行整个父查询,返回最后的结果。   查看多表的数据也可使用表连接,表连接(join on...),表连接都可用子查询替换,但有的子查询不能用表连接替换,子查询比较灵活,方便,形式多样,适合于作为查询的筛选条件。   子查询按照相关性分类 1.相关子查询   必须依赖于它所属的外部查询,不能独立地调用它。   外部查询返回一行,子查询就执行一次。 2.非相关子查询   独立于外部查询的子查询。   子查询总共执行一次,执行完毕后后将值传递给外部查询。   需要注意的是相关子查询主查询执行一回,子查询就执行一回,十分耗费时间,尤其是当数据多的时候。 子查询按照返回的结果集分类 1.单值子查询   只有返回且仅返回一行、一列数据的子查询才能当成单值子查询。当子查询跟随在=、!=、<、<=、>、>=,<> 之后,或子查询用作表达式,只能使用单值子查询。 2.多值子查询   如果子查询是多行单列的子查询,这样的子查询的结果集其实是一个集合

SQL Server: IF EXISTS massively slowing down a query

為{幸葍}努か 提交于 2019-12-23 09:27:59
问题 (SQL Server 2012 being used) I found some topics on query optimization, and comparing EXISTS to COUNT, but I couldn't find this exact problem. I have a query that looks something like this: select * from tblAccount as acc join tblUser as user on acc.AccountId = user.AccountId join tblAddress as addr on acc.AccountId = addr.AccountId ... **a few more joins** where acc.AccountId in ( select * accountid from (select accountid, count(*) from tblUser where flag = 1 group by accountId) as tbl where

How to wait until File.Exists?

一个人想着一个人 提交于 2019-12-23 06:58:42
问题 I have an app, listening for the *.log file in a chosen folder. I used FileSystemWatcher . But there is a problem. The other app responsible for making that file takes following steps: Make a *.gz file Unpack it to txt file (some random file name) Change the *.txt name to proper one with *.log extension. And I can not change this behaviour. So I made 2 FileSystemWatcher s for *.gz, and *.txt files. Why? Because this app sometimes doesn't unpack the gz file, and sometimes doesn't rename the

NodeJS + Mongo: Insert if not exists, otherwise - update

丶灬走出姿态 提交于 2019-12-23 06:49:08
问题 I have an object in my mongodb collection. Its schema is: { "instruments": ["A", "B", "C"], "_id": { "$oid": "508510cd6461cc5f61000001" } } My collection may have such object, but may not. I need to check if object with key "instruments" exists ( please, notе, I don't know what value "instrument" is at this time, it may contain any value or an array ), and if exists - perform update, otherwise – insert a new value. How can I do this? collection.find( { "instruments" : { $exists : true } },