I am using the DBI
library in R to establish a connection to an MS Access DB (in this example called "db") and then using the DBI dbGetQuery()
function to pass MS Access SQL query seen below. If I run this example code segment without attempting to define format it creates a new table as expected. What I cannot determine is whether or not it is possible to define the format for a data type within the same query? If it is possible, what the syntax is for defining format within the CREATE TABLE statement.
Without attempting to format:
dbGetQuery(db, "CREATE TABLE MyTable
(
Table_ID AutoIncrement PRIMARY KEY,
Location CHAR NOT NULL,
Event_Date DATE NOT NULL,
Species_Code CHAR NOT NULL,
Length DOUBLE,
Weight DOUBLE,
Sex CHAR
)")
With attempting to format date, results in a syntax error:
dbGetQuery(db, "CREATE TABLE MyTable
(
Table_ID AutoIncrement PRIMARY KEY,
Location CHAR NOT NULL,
Event_Date DATE NOT NULL FORMAT \"yyyy/mm/dd\",
Species_Code CHAR NOT NULL,
Length DOUBLE,
Weight DOUBLE,
Sex CHAR
)")