I am running Dgraph database and the interface through the suggested docker images. Is it possible to run a command that drops all the data from the database and keeps the schema? Or at the very least drop both the data and schema? Or would I just have to delete the docker images and rebuild them?
Asked
Active
Viewed 2,935 times
2 Answers
23
Unfortunatelly, currently there's only command for dropping both schema and all data. You'll have to use the following HTTP call (or use the query directly in Ratel dashboard, since it uses HTTP communication):
curl -X POST localhost:8080/alter -d '{"drop_all": true}'
There's also possibility to drop a predicate:
curl -X POST localhost:8080/alter -d '{"drop_attr": "your_predicate_name"}'

Ondrej Slinták
- 31,386
- 20
- 94
- 126
-
1Thank you for that, I could not find it anywhere! – Errol Hassall Mar 29 '18 at 21:30
-
3Mind that it doesn't really remove all traces of previously existing nodes as the UID sequence will not be reset. – Coyote Aug 09 '18 at 12:08
-
2Following the second example, you can drop the data only, just by doing curl -X POST localhost:8080/alter -d '{"drop_op": "DATA"}'` – blasrodri May 15 '20 at 07:43
3
Drop all data from Dgraph Ratel itself by navigating to the 'Schema' section and click 'Bulk Edit'. There it gives an option to Drop all data along with schema as a button 'Drop All'. Click 'Drop All' button, then enter 'DROP ALL' in the text box appeared in the pop-up and click 'Drop All' button. It removes all schemas and data

Praveen Gupta
- 121
- 1
- 1