Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is more related to the type of the column value, not how the column is selected. This information is stored in <a href="http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getTypeInfo%28%29" rel="nofollow noreferrer"><code>DatabaseMetaData#getTypeInfo()</code></a>. The column <code>SEARCHABLE</code> can return either <a href="http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#typePredNone" rel="nofollow noreferrer"><code>DatabaseMetaData.typePredNone</code></a> (not searchable) or other values.</p> <blockquote> <p>9: <strong>SEARCHABLE</strong> short => can you use <code>"WHERE"</code> based on this type:</p> <ul> <li><code>typePredNone</code> - No support</li> <li><code>typePredChar</code> - Only supported with <code>WHERE .. LIKE</code></li> <li><code>typePredBasic</code> - Supported except for <code>WHERE .. LIKE</code></li> <li><code>typeSearchable</code> - Supported for all <code>WHERE ..</code> </li> </ul> </blockquote> <p>Here's a snippet which displays this information:</p> <pre><code>DatabaseMetaData databaseMetaData = connection.getMetaData(); ResultSet typeInfo = databaseMetaData.getTypeInfo(); System.out.println("type name | data type | searchable"); System.out.println("-------------------------------+-----------+------------"); while (typeInfo.next()) { String typeName = typeInfo.getString("TYPE_NAME"); int dataType = typeInfo.getInt("DATA_TYPE"); boolean searchable = typeInfo.getShort("SEARCHABLE") != DatabaseMetaData.typePredNone; System.out.printf("%-30s | %-9d | %-9s%n", typeName , dataType, searchable); } </code></pre> <p>This yields something like following on a PostgreSQL 8.4 connection:</p> <pre> type name | data type | searchable -------------------------------+-----------+------------ bool | -7 | true bytea | -2 | true char | 1 | true name | 12 | true int8 | -5 | true bigserial | -5 | true int2 | 5 | true int2vector | 1111 | true int4 | 4 | true serial | 4 | true regproc | 1111 | true text | 12 | true (*snip*, it were about 270 rows, all TRUE by the way) </pre> <p>The <code>data type</code> is correlatable with <a href="http://java.sun.com/javase/6/docs/api/java/sql/ResultSetMetaData.html#getColumnType%28int%29" rel="nofollow noreferrer"><code>ResultSetMetaData#getColumnType()</code></a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload