Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 43114D563 for ; Tue, 6 Nov 2012 11:12:08 +0000 (UTC) Received: (qmail 8912 invoked by uid 500); 6 Nov 2012 11:12:06 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 8562 invoked by uid 500); 6 Nov 2012 11:12:06 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 8517 invoked by uid 99); 6 Nov 2012 11:12:05 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2012 11:12:05 +0000 Received: from localhost (HELO mail-la0-f52.google.com) (127.0.0.1) (smtp-auth username rnewson, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2012 11:12:04 +0000 Received: by mail-la0-f52.google.com with SMTP id s15so220779lag.11 for ; Tue, 06 Nov 2012 03:12:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.135.139 with SMTP id ps11mr686983lab.29.1352200322738; Tue, 06 Nov 2012 03:12:02 -0800 (PST) Received: by 10.112.99.130 with HTTP; Tue, 6 Nov 2012 03:12:02 -0800 (PST) In-Reply-To: References: <015501cdbbd3$4b67a670$e236f350$@charter.net> Date: Tue, 6 Nov 2012 11:12:02 +0000 Message-ID: Subject: Re: Clearing a database. From: Robert Newson To: "user@couchdb.apache.org" Content-Type: multipart/alternative; boundary=f46d0435bf4ee6e9a104cdd1ab5f --f46d0435bf4ee6e9a104cdd1ab5f Content-Type: text/plain; charset=ISO-8859-1 There's no current mechanism to delete all documents without deleting the database itself and recreating it, however it would be a fairly easy feature to add; just write a new empty #db_header{}. On 6 November 2012 08:26, Dave Cottlehuber wrote: > On 6 November 2012 05:00, Kevin Burton wrote: > > I would like to clear all documents out of the database. What would be a > > command that would do that? I can remove an individual document but I am > not > > sure how to remove all documents. > > > > Hi Kevin, > > As CouchDB stores versions of every document change (until after > compaction) what you've asked for is *only* achievable by the CouchDB > equivalent of "DROP TABLE, CREATE TABLE". You can delete all the > documents but the db will retain, even after compaction, stubs of the > old document versions. This cruft is what gives CouchDB its superior > replication powers, so it's necessary. Without these stubs, the DB has > no way of comparing doc versions from another DB instance, and knowing > which are common, and which should be the leaf versions to expose as > conflicts: http://guide.couchdb.org/draft/conflicts.html > > Deleting a DB using the HTTP API, with basic authentication, is as easy as > : > > $ curl -Hcontent-type:application/json -vX PUT > http://admin:password@localhost:5984/newdb > * About to connect() to localhost port 5984 (#0) > * Trying ::1... > * Connection refused > * Trying 127.0.0.1... > * connected > * Connected to localhost (127.0.0.1) port 5984 (#0) > * Server auth using Basic with user 'admin' > > PUT /newdb HTTP/1.1 > > Authorization: Basic YWRtaW46cGFzc3dk > > User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 > OpenSSL/0.9.8r zlib/1.2.5 > > Host: localhost:5984 > > Accept: */* > > content-type:application/json > > > < HTTP/1.1 201 Created > < Server: CouchDB/1.3.0a- (Erlang OTP/R15B02) > < Location: http://localhost:5984/newdb > < Date: Tue, 06 Nov 2012 08:21:10 GMT > < Content-Type: text/plain; charset=utf-8 > < Content-Length: 12 > < Cache-Control: must-revalidate > < > {"ok":true} > * Connection #0 to host localhost left intact > * Closing connection #0 > > > $ curl -Hcontent-type:application/json -vX DELETE > http://admin:password@localhost:5984/newdb > > * About to connect() to localhost port 5984 (#0) > * Trying ::1... > * Connection refused > * Trying 127.0.0.1... > * connected > * Connected to localhost (127.0.0.1) port 5984 (#0) > * Server auth using Basic with user 'admin' > > DELETE /newdb HTTP/1.1 > > Authorization: Basic YWRtaW46cGFzc3dk > > User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 > OpenSSL/0.9.8r zlib/1.2.5 > > Host: localhost:5984 > > Accept: */* > > content-type:application/json > > > < HTTP/1.1 200 OK > < Server: CouchDB/1.3.0a- (Erlang OTP/R15B02) > < Date: Tue, 06 Nov 2012 08:21:18 GMT > < Content-Type: text/plain; charset=utf-8 > < Content-Length: 12 > < Cache-Control: must-revalidate > < > {"ok":true} > > * Connection #0 to host localhost left intact > * Closing connection #0 > > Possibly a little too easy. > > A+ > Dave > --f46d0435bf4ee6e9a104cdd1ab5f--