[Special Characters][A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z]
As you know, case is a conditional expression that you can use to either search for rows in a table when a condition is true or compare a table field to a statement in the case expression. So consider the following where you only look at the first 10 rows in the countries table. The Case expression indicates that if the id is less than five, return the word "Low" and if the id is greater than five, return the word "high". Notice what happens when Denmark, with an id of exactly five, gets returned.
The COALESCE function in SQL returns the first non-NULL expression among its arguments.
Suppose you want to find the constraints on a particular table. You try something like this:
Okay. That looks like it works. At a minimum, it is telling me that the countries table has a primary key named "countries_pkey". Also, for some strange reason, it has two unique constraints named "country_name_uk" and "country_name_unique".
However consider table names with multiple words separated by underscores. If you are used to postmodern turning everything nicely into hyphens, you might try something like:
(query (:select '* :from 'information-schema.table-constraints :where (:= 'table-name "countries-hyphenated-for-some-reason")))
That will not work. Remember that you have to provide the actual string name of the table. Because sql does not like hyphens and demands underscores, the correct query in postmodern would look like this:
(query (:select '* :from 'information-schema.table-constraints :where (:= 'table-name "countries_hyphenated_for_some_reason")))
The query in this function generates information on the foreign key constraints in a database. Ignoring all the postgresql internal table names, while this looks complicated, the only additional items really here are : as the op for getting an array index, :generate-series, and :array-upper
The simplest use of count looks like this:
To create a B-tree index on the column title in the table films:
To create an index on the postmodern expression lower so as to generate efficient case insensitive searches
Postmodern examples >