Skip to content
Advertisement

Tag: sql

Does using “LIMIT 1” speed up a query on a primary key?

If I have a primary key of say id and I do a simple query for the key such as, Will it find one row and then stop looking as it is a primary key, or would it be better to tell mysql to limit its select by using LIMIT 1? For instance: Answer Does using “LIMIT 1” speed up

Dynamically name indexes in SQL Server 2005?

As most people who work with Sql Server know, you can declare a temporary table like so: …this will create a primary key and a default constraint on this temporary table; the names for these objects will be unique, dynamically created by Sql Server. Is it possible to create a dynamically named index for the table after it’s been created?

Referring to a Column Alias in a WHERE Clause

I get “invalid column name daysdiff”. Maxlogtm is a datetime field. It’s the little stuff that drives me crazy. Answer Normally you can’t refer to field aliases in the WHERE clause. (Think of it as the entire SELECT including aliases, is applied after the WHERE clause.) But, as mentioned in other answers, you can force SQL to treat SELECT to

Using SELECT for simple BOOLEAN evaluation

I want to test some evaluations without working on any table. For example, you can write I want to achieve something like this: I know that most engines don’t have the concept of a boolean data type, but I don’t know how their internal work (even if I guess everything <> 0 is true, like in C). Anyway, the format

Function as parameter to another function in Postgres

Can I create a user defined function in Postgres either through the C-Language Function API or by using pl/pgsql which accepts a callback function as parameter? As far as I see there is no way to do this through the C-Language API since it only accepts sql datatypes and there is no datatype for function. But maybe I’m missing something?

Superkey, candidate key & primary key

Can any kind soul clarify my doubts with a simple example below and identify the superkey, candidate key and primary key? I know there are a lot of posts and websites out there explaining the differences between them. But it looks like all are generic definitions. Example: So from the above example, I can know StudentNumber is a primary key.

Advertisement