exists

How to check if a column exists in a SQL Server table?

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to add a specific column if it is does not exist. I have something like this, but it always returns false: IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myTableName' AND COLUMN_NAME = 'myColumnName') How can I check if a column exists in a table of SQL Server database? 回答1: SQL Server 2005 onwards: IF EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'columnName' AND Object_ID = Object_ID(N'schemaName.tableName')) BEGIN -- Column Exists END Martin Smith's version is shorter: IF COL_LENGTH('schemaName.tableName',

What kind of connection exists between innerRadiusRatio and thicknessRatio from GradientDrawable class?

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Let's supposed we've got a ring with inner radius R2 and outer radius R1. According documentation: Inner radius of the ring expressed as a ratio of the ring's width.For instance, if innerRadiusRatio=9, then the inner radius equals the ring's width divided by 9 As I understand this means that innerRadiusRatio = 2*R1 / R2 . About thicknessRatio there is that: Thickness of the ring expressed as a ratio of the ring's width. For instance, if thicknessRatio=3, then the thickness equals the ring's width divided by 3 . So thicknessRatio =

git push: refs/heads/my/subbranch exists, cannot create

匿名 (未验证) 提交于 2019-12-03 02:46:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is this not possible to create somme sub-sub-folder in a repo on a server? if i do: git push origin dev/master everything work find but if i do git push origin dev/sub/master i got this: error: 'refs/heads/dev/sub' exists; cannot create 'refs/heads/dev/sub/master' i checked with "git branch -r" and directly with ssh, there isn't dev/sub folder already created. what's wrong? 回答1: It's not a folder that exists, it's a branch . (Well, there may be a folder/directory involved somewhere―or maybe not, as references get "packed" and stop existing

Python: os.path.exists vs os.path.isdir

匿名 (未验证) 提交于 2019-12-03 02:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm checking to see if a directory exists, but I noticed I'm using path.exists instead of path.isdir. Both work just fine, but I'm curious as to what the advantages are for using isdir instead of exists. 回答1: os.path.exists will also return True if there's a regular file with that name. os.path.isdir will only return True if that path exists and is a directory. 回答2: Just like it sounds like: if the path exists, but is a file and not a directory, isdir will return False . Meanwhile, exists will return True in both cases. 回答3: Most of the time

Boto3, python and how to handle errors

匿名 (未验证) 提交于 2019-12-03 02:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I just picked up python as my go-to scripting language and I am trying to figure how to do proper error handling with boto3. I am trying to create an IAM user: def create_user(username, iam_conn): try: user = iam_conn.create_user(UserName=username) return user except Exception as e: return e When the call to create_user succeeds, i get a neat object that contains the http status code of the API call and the data of the newly created user. Example: {'ResponseMetadata': {'HTTPStatusCode': 200, 'RequestId': 'omitted' }, u'User': {u'Arn': 'arn

Fastest way to check if a file exist using standard C++/C++11/C?

匿名 (未验证) 提交于 2019-12-03 02:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I would like to find the fastest way to check if a file exist in standard C++11, C++, or C. I have thousands of files and before doing something on them I need to check if all of them exist. What can I write instead of /* SOMETHING */ in the following function? inline bool exist ( const std :: string & name ) { /* SOMETHING */ } 回答1: Well I threw together a test program that ran each of these methods 100,000 times, half on files that existed and half on files that didn't. #include #include #include inline bool exists_test0 ( const

Foreign key issue:ERROR 1005 (HY000): Can't create table (errno: 150)

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm getting this error: ERROR 1005 (HY000): Can't create table (errno: 150); I know it has something to do with the foreign keys but I have checked to see if they have the same info types etc and I can't find the problem. The video, director actor, role and member create; the rest do not. CREATE TABLE IF NOT EXISTS actor ( actorNo VARCHAR(15) NOT NULL, actorName VARCHAR(40) NOT NULL, PRIMARY KEY (actorNo) ) ENGINE=InnoDB; CREATE TABLE IF NOT EXISTS staff ( StaffNo VARCHAR (15) NOT NULL, name VARCHAR(40) NOT NULL, position VARCHAR(40) ,

MYSQL中in or union的效率问题

瘦欲@ 提交于 2019-12-03 02:35:44
今天有人问in一堆条件的sql如何优化。这个很自然就想到用union来代替in来提高效率,网上很多例子也是这么说的 http://blog.csdn.net/adparking/article/details/6678911 http://hi.baidu.com/dereky/blog/item/382c2df536c0532cbc310929.html http://www.cnblogs.com/xwblog/archive/2012/04/09/2438737.html 可是我在本机做实验为什么有相反地结果呢... EXPLAIN SELECT * from employees where employees.first_NAME ='Georgi' UNION ALL SELECT * from employees where employees.first_NAME ='Bezalel' 这条语句执行结果481条,执行时间为0.35s 1 PRIMARY employees ALL 300141 Using where 2 UNION employees ALL 300141 Using where UNION RESULT <union1,2> ALL explain SELECT * FROM employees WHERE employees.first_name

PostgreSQL create table if not exists

匿名 (未验证) 提交于 2019-12-03 02:35:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In a MySQL script you can write: CREATE TABLE IF NOT EXISTS foo ...; ... other stuff ... and then you can run the script many times without re-creating the table. How do you do this in PostgreSQL? 回答1: This feature has been implemented in Postgres 9.1 : CREATE TABLE IF NOT EXISTS myschema.mytable (i integer); For older versions , here is a function to work around it: CREATE OR REPLACE FUNCTION create_mytable () RETURNS void AS $func$ BEGIN IF EXISTS (SELECT 1 FROM pg_catalog.pg_tables WHERE schemaname = 'myschema' AND tablename = 'mytable')

MySQL Alter syntax to drop a column if it exists [closed]

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is the syntax to drop a column in a MySQL table, if that column exists on version 4.0.18? 回答1: For MySQL, there is none: MySQL Feature Request . Allowing this is arguably a really bad idea, anyway: IF EXISTS indicates that you're running destructive operations on a database with (to you) unknown structure. There may be situations where this is acceptable for quick-and-dirty local work, but if you're tempted to run such a statement against production data (in a migration etc.), you're playing with fire. But if you insist, it's not