key {PivotalR} | R Documentation |
This function gets or sets the primary key for a db.obj
table.
key(x) key(x) <- value
x |
is a db.obj object. |
value |
must be a string. |
key()
will return the primary key of a table. If the primary key is not set, key()
will return the character 0
. If key()
is being used to set the primary key, then value
must be a string, and it must match one of the column names in the table.
If this function is used to change the primary key to a new column name, this function does NOT check if all the values in that column are unique.
The return value is the primary key of the table.
Author: Predictive Analytics Team at Pivotal Inc.
Maintainer: Frank McQuillan, Pivotal Inc. fmcquillan@pivotal.io
lk
or lookat
Displays the contents of a db.obj
object.
## 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) ## create a table from the example data.frame "abalone" tmp <- as.db.data.frame(abalone, conn.id = cid, verbose = FALSE) x <- db.data.frame(content(tmp), key = 'id', conn.id = cid, verbose = FALSE) ## getting the primary key key(x) # Display the primary key for x ## Changing the primary key key(x) <- 'length' db.disconnect(cid, verbose = FALSE) ## End(Not run)