Learn R Programming

RMySQL (version 0.4-6)

make.SQL.names: Make R/S identifiers into legal SQL identifiers.

Description

Produce legal SQL identifiers from an R/S chacter vector.

Usage

make.SQL.names(snames, keywords=.SQL92Keywords, unique=T, allow.keywords=T)

Arguments

snames
a character vector of R/S identifiers (syntactic names).
keywords
a character vector of SQL keywords. It defaults to .SQL92Keywords.
unique
logical describing whether the resulting set of SQL names should be unique. Its default is TRUE. Following the SQL 92 standard, uniqueness of SQL identifiers is determined regardless of whether letters are upper or lower case.
allow.keywords
logical describing whether SQL keywords should be allowed in the resulting set of SQL names. Its default is TRUE

Value

  • a character vector with legal SQL identifiers.

References

The set of SQL keywords is stored in the character vector .SQLKeywords and reflects the SQL ANSI/ISO standard as documented in "X/Open SQL and RDA", 1994, ISBN 1-872630-68-8. Users can easily override or update this vector.

Bugs

The current mapping is not guaranteed to be fully reversible: some SQL identifiers that get mapped into R/S identifiers with make.names and then back to SQL with make.SQL.names will not be equal to the original SQL indetifiers (e.g., compound SQL identifiers of the form username.tablename will loose the dot ``.'').

Details

The algorithm first invokes make.names and then replaces each occurrence of a dot ``.'' by an underscore ``_''.

See Also

isSQLKeyword make.names getTable existsTable assignTable removeTable dbConnect

Examples

Run this code
# This example shows how we could export a bunch of data.frames
# into tables on a remote database.

con <- dbConnect("Oracle", user="iptraffic", pass = pwd)

export <- c("trantime.email", "trantime.print", "round.trip.time.email")
tabs <- make.SQL.names(export, unique = T, allow.keywords = T)

for(i in seq(along = export) )
   assignTable(con, name = tabs[i],  get(export[i]))

Run the code above in your browser using DataLab