dbAddIndex: Adds a Primary Key to an existing table

Description Usage Arguments Details See Also

Description

'dbCreateTable' does not directly support adding primary or secondary indexes to the table being created. Properly chosen indexing of tables increases query performance.

Usage

1
dbAddIndex(con, name, index, unique = FALSE, ...)

Arguments

con

a DBConnection oject

name

a character string specifying the name of an existing DBMS table

index

a character vector of column names which will form the index

unique

boolean, default = FALSE; If set to true, the constraint that all rows must have unique values for the index

To specify a composite Indexfor the 'symbol' and 'date' columns use

primary_key = c("symbol","date" )

For a table with a Unique Index defined, each records must have a unqiue index value. Attempting to 'INSERT' records into the DB will with duplicate values on a unique index to an existing record causes an ERROR

Details

The default 'dbAddIndex()' method performs checks that the targeted table exists and that the columns specified for the index exist in the target table. the method throws an error if either condition is FALSE

The sql generation uses the function 'sqlAQddIndex()' another S4 generic defined in this package. Default sql generation is appropriate for MariaDB and MySQL.

See Also

Other DBIConnection generics: dbAddPrimaryKey, dbDeleteAllRecords, dbDropTable, dbReplaceInTable, dbUpdateTable


schardtbc/DBIExt documentation built on June 7, 2019, 2:39 p.m.