delete-methods: Safely delete a 'db.obj' object or a table/view in the...

deleteR Documentation

Safely delete a db.obj object or a table/view in the database

Description

This function deletes a db.data.frame object together with the table/view that it points to. It deletes a db.Rquery object. It can also directly delete a table or view in the database. When applied onto some composite data objects, it deletes the data table wrapped by them.

Usage


## S4 method for signature 'db.data.frame'
delete(x, cascade = FALSE)

## S4 method for signature 'db.Rquery'
delete(x)

## S4 method for signature 'character'
delete(x, conn.id = 1, is.temp = FALSE, cascade =
FALSE)

## S4 method for signature 'bagging.model'
delete(x)

Arguments

x

The signature of the method.

A db.data.frame object, which points to a table or view in the database;

Or a db.Rquery object, which represents some operations on an existing db.data.frame object;

Or a string, the table/view name to delete in the database. In the this case, the result model tables wrapped by model, residuals and statistics will be deleted.

conn.id

An integer, default is 1. The connection ID to the database.

is.temp

A logical, default is FALSE. Whether the table/view is temporary.

cascade

A logical, default is FALSE. Whether to delete objects together with all the objects depending on it.

Details

When a db.data.frame object is deleted, the table/view that is associated with it is also deleted.

Value

When x is db.data.frame or table/view name, this function returns a logical value. which is TRUE if the deletion is successful.

No value is returned if x is db.Rquery

Author(s)

Author: Predictive Analytics Team at Pivotal Inc.

Maintainer: Frank McQuillan, Pivotal Inc. fmcquillan@pivotal.io

See Also

db.data.frame creates an object pointing to a table/view in the database.

db.objects lists all tables and views in a database together with their schema.

db.existsObject tests whether a table/view exists in the database.

as.db.data.frame creates a db.data.frame from a data.frame, a data file or a db.Rquery.

Examples

## Not run: 


## set up the database connection
## Assume that .port is port number and .dbname is the database name
cid <- db.connect(port = .port, dbname = .dbname, verbose = FALSE)

delete("abalone", cid, is.temp = TRUE)

delete("abalone", cid, is.temp = FALSE)

delete("abalone", conn.id = cid)
x <- as.db.data.frame(abalone, "abalone", conn.id = cid)

lk(x, 10)

y <- as.db.data.frame(abalone, "abalone", conn.id = cid, is.temp = TRUE)

lk(y, 10)

db.existsObject("abalone", cid, is.temp = TRUE)

db.existsObject("abalone", cid, is.temp = FALSE)

delete("abalone", cid)

p <- db.objects()
p[p == "abalone"]

## Example: delete multiple tables
## all table in public schema start with "ornste"
to.delete <- db.objects("public.ornste", conn.id = cid)
for (table.name in to.delete) delete(table.name, conn.id = cid)

db.disconnect(cid, verbose = FALSE)

## End(Not run)

greenplum-db/GreenplumR documentation built on Sept. 2, 2023, 8:09 a.m.