Rob Lachlan
Rob Lachlan

Reputation: 14469

How can I add an index to a table using ClojureQL?

Using any clojure database/orm library, how can I create an index in a database? I can't seem to find any relevant examples. (I'm most interested in ClojureQL and clojure.java.jdbc, since I'm currently using those).

EDIT: OK, so I figured out a way to do this with clojure.java.jdbc:

(ns foo
  (:require [clojure.java [jdbc :as sql]]))

(sql/with-connection db
  (sql/do-commands
     "CREATE INDEX IF NOT EXISTS my_index ON some_table (a_column)" ))

But I'd really like to know how to do this in ClojureQL.

Upvotes: 3

Views: 365

Answers (2)

NielsK
NielsK

Reputation: 6956

ClojureQL is meant for generating the Data Manipulation part of SQL, CRUDing data, but not structure. To generate and execute the Data Definition side of SQL under Clojure, have a look at the Lobos library, which is being made to compliment ClojureQL in this regard.

Upvotes: 2

Joost Diepenmaat
Joost Diepenmaat

Reputation: 17771

IIRC, ClojureQL doesn't have any support for manipulation of database schemas. It's pretty much geared only towards insertion and querying.

Upvotes: 2

Related Questions