What is the point (if any) in having a table in a database with only one row?
A relational database stores things as relations: a tuples of data satisfying some relation.
Like, this one: "a VAT
of this many percent is in effect in my country now".
If only one tuple satisifies this relation, then yes, it will be the only one in the table.
SQL
cannot store variables: it can store a set consisting of 1
element, this is a one-row table.
Also, SQL
is a set based language, and for some operations you need a fake set of only one row, like, to select a constant expression.
You cannot just SELECT
out of nothing in Oracle
, you need a FROM
clause.
Oracle
has a pseudotable, dual
, which contains only one row and only one column.
Once, long time ago, it used to have two rows (hence the name dual
), but lost its second row somewhere on its way to version 7
.
MySQL
has this pseudotable too, but MySQL
is able to do selects without FROM
clause. Still, it's useful when you need an empty rowset: SELECT 1 FROM dual WHERE NULL
I've just observed in some code I'm reviewing three different tables that contain three different kinds of certificates (a la SSL
), each having exactly one row. I don't understand why this isn't made into one large table; I assume I'm missing something.
It may be a kind of "have it all or lose" scenario, when all three certificates are needed at once:
SELECT *
FROM ssl1
CROSS JOIN
ssl2
CROSS JOIN
ssl3
If any if the certificates is missing, the whole query returns nothing.